various small code cleanups and improvements

Largely refactoring work to make the code somewhat nicer to work with.
This commit is contained in:
itsmattkc
2019-12-26 19:00:08 +11:00
parent 83077c939e
commit 61c60e00d6
87 changed files with 596 additions and 567 deletions
+5 -5
View File
@@ -130,11 +130,11 @@ void AudioManager::SetOutputDevice(const QAudioDeviceInfo &info)
}
output_ = std::unique_ptr<QAudioOutput>(new QAudioOutput(info, format, this));
connect(output_.get(), SIGNAL(notify()), this, SLOT(OutputNotified()));
connect(output_.get(), &QAudioOutput::notify, this, &AudioManager::OutputNotified);
}
// Un-comment this to get debug information about what the audio output is doing
//connect(output_.get(), SIGNAL(stateChanged(QAudio::State)), this, SLOT(OutputStateChanged(QAudio::State)));
//connect(output_.get(), &QAudioOutput::stateChanged, this, &AudioManager::OutputStateChanged);
}
void AudioManager::SetOutputParams(const AudioRenderingParams &params)
@@ -169,12 +169,12 @@ AudioManager::AudioManager() :
input_file_(nullptr),
refreshing_devices_(false)
{
connect(&refresh_thread_, SIGNAL(ListsReady()), this, SLOT(RefreshThreadDone()));
connect(&refresh_thread_, &AudioRefreshDevicesThread::ListsReady, this, &AudioManager::RefreshThreadDone);
RefreshDevices();
connect(&output_manager_, SIGNAL(HasSamples()), this, SLOT(OutputManagerHasSamples()));
connect(&output_manager_, SIGNAL(SentSamples(QVector<double>)), this, SIGNAL(SentSamples(QVector<double>)));
connect(&output_manager_, &AudioHybridDevice::HasSamples, this, &AudioManager::OutputManagerHasSamples);
connect(&output_manager_, &AudioHybridDevice::SentSamples, this, &AudioManager::SentSamples);
output_manager_.SetEnableSendingSamples(true);
output_manager_.open(AudioHybridDevice::ReadOnly);
+2 -2
View File
@@ -45,8 +45,8 @@ using DecoderPtr = std::shared_ptr<Decoder>;
* necessitate pre-emptively caching, indexing, or even fully transcoding media before using it which can be implemented
* through the Analyze() function.
*
* A decoder does NOT perform any pixel/sample format conversion. Frames should pass through the PixelFormatConverter
* (olive::pix_fmt_conv) to be utilized in the rest of the rendering pipeline.
* A decoder does NOT perform any pixel/sample format conversion. Frames should pass through the PixelService
* to be utilized in the rest of the rendering pipeline.
*/
class Decoder : public QObject
{
+17 -17
View File
@@ -66,36 +66,36 @@ AVSampleFormat FFmpegCommon::GetFFmpegSampleFormat(const SampleFormat &smp_fmt)
return AV_SAMPLE_FMT_NONE;
}
AVPixelFormat FFmpegCommon::GetFFmpegPixelFormat(const olive::PixelFormat &pix_fmt)
AVPixelFormat FFmpegCommon::GetFFmpegPixelFormat(const PixelFormat::Format &pix_fmt)
{
switch (pix_fmt) {
case olive::PIX_FMT_RGBA8:
case PixelFormat::PIX_FMT_RGBA8:
return AV_PIX_FMT_RGBA;
case olive::PIX_FMT_RGBA16U:
case PixelFormat::PIX_FMT_RGBA16U:
return AV_PIX_FMT_RGBA64;
case olive::PIX_FMT_RGBA16F:
case olive::PIX_FMT_RGBA32F:
case olive::PIX_FMT_INVALID:
case olive::PIX_FMT_COUNT:
case PixelFormat::PIX_FMT_RGBA16F:
case PixelFormat::PIX_FMT_RGBA32F:
case PixelFormat::PIX_FMT_INVALID:
case PixelFormat::PIX_FMT_COUNT:
break;
}
return AV_PIX_FMT_NONE;
}
olive::PixelFormat FFmpegCommon::GetCompatiblePixelFormat(const olive::PixelFormat &pix_fmt)
PixelFormat::Format FFmpegCommon::GetCompatiblePixelFormat(const PixelFormat::Format &pix_fmt)
{
switch (pix_fmt) {
case olive::PIX_FMT_RGBA8:
return olive::PIX_FMT_RGBA8;
case olive::PIX_FMT_RGBA16U:
case olive::PIX_FMT_RGBA16F:
case olive::PIX_FMT_RGBA32F:
return olive::PIX_FMT_RGBA16U;
case olive::PIX_FMT_INVALID:
case olive::PIX_FMT_COUNT:
case PixelFormat::PIX_FMT_RGBA8:
return PixelFormat::PIX_FMT_RGBA8;
case PixelFormat::PIX_FMT_RGBA16U:
case PixelFormat::PIX_FMT_RGBA16F:
case PixelFormat::PIX_FMT_RGBA32F:
return PixelFormat::PIX_FMT_RGBA16U;
case PixelFormat::PIX_FMT_INVALID:
case PixelFormat::PIX_FMT_COUNT:
break;
}
return olive::PIX_FMT_INVALID;
return PixelFormat::PIX_FMT_INVALID;
}
+2 -2
View File
@@ -18,12 +18,12 @@ public:
/**
* @brief Returns a native pixel format that can be used to convert from a native frame to an AVFrame with minimal data loss
*/
static olive::PixelFormat GetCompatiblePixelFormat(const olive::PixelFormat& pix_fmt);
static PixelFormat::Format GetCompatiblePixelFormat(const PixelFormat::Format& pix_fmt);
/**
* @brief Returns an FFmpeg pixel format for a given native pixel format
*/
static AVPixelFormat GetFFmpegPixelFormat(const olive::PixelFormat& pix_fmt);
static AVPixelFormat GetFFmpegPixelFormat(const PixelFormat::Format& pix_fmt);
/**
* @brief Returns a native sample format type for a given AVSampleFormat
+4 -4
View File
@@ -141,10 +141,10 @@ bool FFmpegDecoder::Open()
// Note that FFmpeg doesn't support float formats
switch (ideal_pix_fmt) {
case AV_PIX_FMT_RGBA:
output_fmt_ = olive::PIX_FMT_RGBA8;
output_fmt_ = PixelFormat::PIX_FMT_RGBA8;
break;
case AV_PIX_FMT_RGBA64:
output_fmt_ = olive::PIX_FMT_RGBA16U;
output_fmt_ = PixelFormat::PIX_FMT_RGBA16U;
break;
default:
// We should never get here, but if we do there's nothing we can do with this format
@@ -224,13 +224,13 @@ FramePtr FFmpegDecoder::RetrieveVideo(const rational &timecode)
FramePtr frame_container = Frame::Create();
frame_container->set_width(frame->width);
frame_container->set_height(frame->height);
frame_container->set_format(static_cast<olive::PixelFormat>(output_fmt_));
frame_container->set_format(static_cast<PixelFormat::Format>(output_fmt_));
frame_container->set_timestamp(Timecode::timestamp_to_time(target_ts, avstream_->time_base));
frame_container->allocate();
// Convert pixel format/linesize if necessary
uint8_t* dst_data = reinterpret_cast<uint8_t*>(frame_container->data());
int dst_linesize = frame_container->width() * PixelService::BytesPerPixel(static_cast<olive::PixelFormat>(output_fmt_));
int dst_linesize = frame_container->width() * PixelService::BytesPerPixel(static_cast<PixelFormat::Format>(output_fmt_));
// Perform pixel conversion
sws_scale(scale_ctx_,
+1 -1
View File
@@ -115,7 +115,7 @@ bool FFmpegEncoder::OpenInternal()
}
// This is the format we will expect frames received in Write() to be in
olive::PixelFormat native_pixel_fmt = params().video_params().format();
PixelFormat::Format native_pixel_fmt = params().video_params().format();
// This is the format we will need to convert the frame to for swscale to understand it
video_conversion_fmt_ = FFmpegCommon::GetCompatiblePixelFormat(native_pixel_fmt);
+1 -1
View File
@@ -56,7 +56,7 @@ private:
AVStream* video_stream_;
AVCodecContext* video_codec_ctx_;
SwsContext* video_scale_ctx_;
olive::PixelFormat video_conversion_fmt_;
PixelFormat::Format video_conversion_fmt_;
AVStream* audio_stream_;
AVCodecContext* audio_codec_ctx_;
+4 -4
View File
@@ -28,7 +28,7 @@
Frame::Frame() :
width_(0),
height_(0),
format_(olive::PIX_FMT_INVALID),
format_(PixelFormat::PIX_FMT_INVALID),
sample_count_(0),
timestamp_(0)
{
@@ -89,12 +89,12 @@ void Frame::set_native_timestamp(const int64_t &timestamp)
native_timestamp_ = timestamp;
}*/
const olive::PixelFormat &Frame::format()
const PixelFormat::Format &Frame::format()
{
return format_;
}
void Frame::set_format(const olive::PixelFormat &format)
void Frame::set_format(const PixelFormat::Format &format)
{
format_ = format;
}
@@ -128,7 +128,7 @@ void Frame::allocate()
{
// Assume this frame is intended to be a video frame
if (width_ > 0 && height_ > 0) {
data_.resize(PixelService::GetBufferSize(static_cast<olive::PixelFormat>(format_), width_, height_));
data_.resize(PixelService::GetBufferSize(static_cast<PixelFormat::Format>(format_), width_, height_));
} else if (sample_count_ > 0) {
data_.resize(audio_params_.samples_to_bytes(sample_count_));
}
+3 -3
View File
@@ -82,8 +82,8 @@ public:
*
* Currently this will either be an olive::PixelFormat (video) or an olive::SampleFormat (audio).
*/
const olive::PixelFormat& format();
void set_format(const olive::PixelFormat& format);
const PixelFormat::Format& format();
void set_format(const PixelFormat::Format& format);
/**
* @brief Returns a copy of the data in this frame as a QByteArray
@@ -128,7 +128,7 @@ private:
int height_;
olive::PixelFormat format_;
PixelFormat::Format format_;
AudioRenderingParams audio_params_;
+5 -5
View File
@@ -84,13 +84,13 @@ bool OIIODecoder::Open()
// Weirdly, switch statement doesn't work correctly here
if (spec.format == OIIO::TypeDesc::UINT8) {
pix_fmt_ = olive::PIX_FMT_RGBA8;
pix_fmt_ = PixelFormat::PIX_FMT_RGBA8;
} else if (spec.format == OIIO::TypeDesc::UINT16) {
pix_fmt_ = olive::PIX_FMT_RGBA16U;
pix_fmt_ = PixelFormat::PIX_FMT_RGBA16U;
} else if (spec.format == OIIO::TypeDesc::HALF) {
pix_fmt_ = olive::PIX_FMT_RGBA16F;
pix_fmt_ = PixelFormat::PIX_FMT_RGBA16F;
} else if (spec.format == OIIO::TypeDesc::FLOAT) {
pix_fmt_ = olive::PIX_FMT_RGBA32F;
pix_fmt_ = PixelFormat::PIX_FMT_RGBA32F;
} else {
qWarning() << "Failed to convert OIIO::ImageDesc to native pixel format";
return false;
@@ -100,7 +100,7 @@ bool OIIODecoder::Open()
is_rgba_ = (spec.nchannels == kRGBAChannels);
pix_fmt_info_ = PixelService::GetPixelFormatInfo(static_cast<olive::PixelFormat>(pix_fmt_));
pix_fmt_info_ = PixelService::GetPixelFormatInfo(static_cast<PixelFormat::Format>(pix_fmt_));
return true;
}
+2 -2
View File
@@ -52,9 +52,9 @@ private:
int height_;
olive::PixelFormat pix_fmt_;
PixelFormat::Format pix_fmt_;
PixelFormatInfo pix_fmt_info_;
PixelFormat::Info pix_fmt_info_;
bool is_rgba_;
+5 -2
View File
@@ -18,22 +18,25 @@ set(OLIVE_SOURCES
${OLIVE_SOURCES}
common/channellayout.h
common/clamp.h
common/constructors.h
common/debug.h
common/debug.cpp
common/define.h
common/filefunctions.h
common/filefunctions.cpp
common/flipmodifiers.h
common/flipmodifiers.cpp
common/lerp.h
common/qtversionabstraction.h
common/qtversionabstraction.cpp
common/range.h
common/rational.h
common/rational.cpp
common/qtversionabstraction.h
common/qtversionabstraction.cpp
common/threadedobject.h
common/threadedobject.cpp
common/timecodefunctions.h
common/timecodefunctions.cpp
common/timelinecommon.h
common/timerange.h
common/timerange.cpp
PARENT_SCOPE
-11
View File
@@ -1,11 +0,0 @@
#include "decibel.h"
#include <QtMath>
double amplitude_to_db(double amplitude) {
return (20.0*(qLn(amplitude)/qLn(10.0)));
}
double db_to_amplitude(double db) {
return qPow(M_E, (db*qLn(10.0))/20.0);
}
-18
View File
@@ -1,18 +0,0 @@
#ifndef DECIBEL_H
#define DECIBEL_H
/**
* @brief Converts an amplitude into a value in decibels
*
* Converts a 0.0-1.0 amplitude into an infinity-0.0 decibel value
*/
double amplitude_to_db(double amplitude);
/**
* @brief Converts decibels into an amplitude value
*
* Converts an infinity-0.0 decibel value into a 0.0-1.0 amplitude
*/
double db_to_amplitude(double db);
#endif // DECIBEL_H
+9
View File
@@ -24,4 +24,13 @@
const int kRGBChannels = 3;
const int kRGBAChannels = 4;
/// The minimum size an icon in ProjectExplorer can be
const int kProjectIconSizeMinimum = 16;
/// The maximum size an icon in ProjectExplorer can be
const int kProjectIconSizeMaximum = 256;
/// The default size an icon in ProjectExplorer can be
const int kProjectIconSizeDefault = 64;
#endif // OLIVECOMMONDEFINE_H
+5
View File
@@ -255,3 +255,8 @@ Timecode::Display Timecode::CurrentDisplay()
{
return static_cast<Timecode::Display>(Config::Current()["TimecodeDisplay"].toInt());
}
void Timecode::SetCurrentDisplay(Timecode::Display d)
{
Config::Current()["TimecodeDisplay"] = d;
}
+1
View File
@@ -46,6 +46,7 @@ public:
};
static Display CurrentDisplay();
static void SetCurrentDisplay(Display d);
/**
* @brief Convert a timestamp (according to a rational timebase) to a user-friendly string representation
+8 -14
View File
@@ -1,20 +1,14 @@
#ifndef TIMELINECOMMON_H
#define TIMELINECOMMON_H
namespace olive {
namespace timeline {
enum MovementMode {
kNone,
kMove,
kTrimIn,
kTrimOut
class Timeline {
public:
enum MovementMode {
kNone,
kMove,
kTrimIn,
kTrimOut
};
};
}
}
#endif // TIMELINECOMMON_H
+2 -2
View File
@@ -99,7 +99,7 @@ void Config::Load()
}
if (reader.hasError()) {
QMessageBox::critical(olive::core.main_window(),
QMessageBox::critical(Core::instance()->main_window(),
QCoreApplication::translate("Config", "Error loading settings"),
QCoreApplication::translate("Config", "Failed to load application settings. This session will "
"use defaults."),
@@ -115,7 +115,7 @@ void Config::Save()
QFile config_file(GetConfigFilePath());
if (!config_file.open(QFile::WriteOnly)) {
QMessageBox::critical(olive::core.main_window(),
QMessageBox::critical(Core::instance()->main_window(),
QCoreApplication::translate("Config", "Error saving settings"),
QCoreApplication::translate("Config", "Failed to save application settings. The application "
"may lack write permissions to this location."),
+17 -5
View File
@@ -50,7 +50,7 @@
#include "widget/menu/menushared.h"
#include "widget/taskview/taskviewitem.h"
Core olive::core;
Core Core::instance_;
Core::Core() :
main_window_(nullptr),
@@ -60,6 +60,11 @@ Core::Core() :
{
}
Core *Core::instance()
{
return &instance_;
}
void Core::Start()
{
//
@@ -117,6 +122,8 @@ void Core::Stop()
// Save Config
//Config::Save();
MenuShared::DestroyInstance();
PanelManager::DestroyInstance();
AudioManager::DestroyInstance();
@@ -131,6 +138,11 @@ MainWindow *Core::main_window()
return main_window_;
}
UndoStack *Core::undo_stack()
{
return &undo_stack_;
}
void Core::ImportFiles(const QStringList &urls, ProjectViewModel* model, Folder* parent)
{
if (urls.isEmpty()) {
@@ -138,7 +150,7 @@ void Core::ImportFiles(const QStringList &urls, ProjectViewModel* model, Folder*
return;
}
olive::task_manager.AddTask(std::make_shared<ImportTask>(model, parent, urls));
TaskManager::instance()->AddTask(std::make_shared<ImportTask>(model, parent, urls));
}
const Tool::Item &Core::tool()
@@ -272,7 +284,7 @@ void Core::CreateNewFolder()
folder,
new_folder);
olive::undo_stack.push(aic);
Core::instance()->undo_stack()->push(aic);
// Trigger an automatic rename so users can enter the folder name
active_project_panel->Edit(new_folder.get());
@@ -322,7 +334,7 @@ void Core::CreateNewSequence()
new_sequence->add_default_nodes();
olive::undo_stack.push(aic);
Core::instance()->undo_stack()->push(aic);
Sequence::Open(new_sequence);
}
@@ -354,7 +366,7 @@ void Core::StartGUI(bool full_screen)
StyleManager::SetStyle(StyleManager::DefaultStyle());
// Set up shared menus
olive::menu_shared.Initialize();
MenuShared::CreateInstance();
// Since we're starting GUI mode, create a PanelFocusManager (auto-deletes with QObject)
PanelManager::CreateInstance();
+23 -9
View File
@@ -30,6 +30,7 @@
#include "window/mainwindow/mainwindow.h"
#include "task/task.h"
#include "tool/tool.h"
#include "undo/undostack.h"
/**
* @brief The main central Olive application instance
@@ -51,6 +52,13 @@ public:
*/
Core();
/**
* @brief Core object accessible from anywhere in the code
*
* Use this to access Core functions.
*/
static Core* instance();
/**
* @brief Start Olive Core
*
@@ -74,6 +82,11 @@ public:
*/
MainWindow* main_window();
/**
* @brief Retrieve UndoStack object
*/
UndoStack* undo_stack();
/**
* @brief Import a list of files
*
@@ -290,18 +303,19 @@ private:
*/
QTimer autorecovery_timer_;
/**
* @brief Application-wide undo stack instance
*/
UndoStack undo_stack_;
/**
* @brief Static singleton core instance
*/
static Core instance_;
private slots:
void SaveAutorecovery();
};
namespace olive {
/**
* @brief Core object accessible from anywhere in the code
*
* Use this to access Core functions.
*/
extern Core core;
}
#endif // CORE_H
+1 -1
View File
@@ -179,7 +179,7 @@ void ExportDialog::accept()
dest_height);
// FIXME: Hardcoded pixel format
VideoRenderingParams video_render_params(dest_width, dest_height, video_tab_->frame_rate().flipped(), olive::PIX_FMT_RGBA32F, olive::kOnline);
VideoRenderingParams video_render_params(dest_width, dest_height, video_tab_->frame_rate().flipped(), PixelFormat::PIX_FMT_RGBA32F, RenderMode::kOnline);
// FIXME: Hardcoded sample format
AudioRenderingParams audio_render_params(audio_tab_->sample_rate_combobox()->currentData().toInt(),
@@ -31,10 +31,10 @@
#include <QCheckBox>
#include <QSpinBox>
#include "core.h"
#include "render/colormanager.h"
#include "streamproperties/audiostreamproperties.h"
#include "streamproperties/videostreamproperties.h"
#include "undo/undostack.h"
FootagePropertiesDialog::FootagePropertiesDialog(QWidget *parent, Footage *footage) :
QDialog(parent),
@@ -117,7 +117,7 @@ void FootagePropertiesDialog::accept() {
static_cast<StreamProperties*>(stacked_widget_->widget(i))->Accept(command);
}
olive::undo_stack.pushIfHasChildren(command);
Core::instance()->undo_stack()->pushIfHasChildren(command);
QDialog::accept();
}
@@ -36,7 +36,7 @@ namespace OCIO = OCIO_NAMESPACE::v1;
ProjectPropertiesDialog::ProjectPropertiesDialog(QWidget *parent) :
QDialog(parent),
working_project_(olive::core.GetActiveProject())
working_project_(Core::instance()->GetActiveProject())
{
QVBoxLayout* layout = new QVBoxLayout(this);
+1 -1
View File
@@ -177,7 +177,7 @@ void SequenceDialog::accept()
audio_params,
name_field_->text());
olive::undo_stack.push(param_command);
Core::instance()->undo_stack()->push(param_command);
} else {
// Set sequence values directly with no undo command
+2 -2
View File
@@ -7,8 +7,8 @@
#include <QLabel>
#include <QVBoxLayout>
#include "core.h"
#include "common/timecodefunctions.h"
#include "undo/undostack.h"
#include "widget/nodeview/nodeviewundo.h"
#include "widget/timelinewidget/undo/undo.h"
@@ -241,7 +241,7 @@ void SpeedDurationDialog::accept()
}
}
olive::undo_stack.pushIfHasChildren(command);
Core::instance()->undo_stack()->pushIfHasChildren(command);
QDialog::accept();
}
+2 -2
View File
@@ -85,13 +85,13 @@ int main(int argc, char *argv[]) {
#endif
// Start core
olive::core.Start();
Core::instance()->Start();
// Run application loop and receive exit code
int exit_code = a.exec();
// Clear core memory
olive::core.Stop();
Core::instance()->Stop();
return exit_code;
}
+4 -4
View File
@@ -57,9 +57,9 @@ ProjectPanel::ProjectPanel(QWidget *parent) :
// Connect toolbar's view change signal to the explorer's view change slot
connect(toolbar,
SIGNAL(ViewChanged(olive::ProjectViewType)),
&ProjectToolbar::ViewChanged,
explorer_,
SLOT(set_view_type(olive::ProjectViewType)));
&ProjectExplorer::set_view_type);
// Set strings
Retranslate();
@@ -120,7 +120,7 @@ void ProjectPanel::ItemDoubleClickSlot(Item *item)
{
if (item == nullptr) {
// If the user double clicks on empty space, show the import dialog
olive::core.DialogImportShow();
Core::instance()->DialogImportShow();
}
// FIXME: Double click Item should do something
@@ -130,7 +130,7 @@ void ProjectPanel::ShowNewMenu()
{
Menu new_menu(this);
olive::menu_shared.AddItemsForNewMenu(&new_menu);
MenuShared::instance()->AddItemsForNewMenu(&new_menu);
new_menu.exec(QCursor::pos());
}
+1 -1
View File
@@ -35,7 +35,7 @@ TaskManagerPanel::TaskManagerPanel(QWidget* parent) :
setWidget(view_);
// Connect task view to the task manager
connect(&olive::task_manager, SIGNAL(TaskAdded(Task*)), view_, SLOT(AddTask(Task*)));
connect(TaskManager::instance(), &TaskManager::TaskAdded, view_, &TaskView::AddTask);
// Set strings
Retranslate();
+6 -6
View File
@@ -31,16 +31,16 @@ ToolPanel::ToolPanel(QWidget *parent) :
Toolbar* t = new Toolbar(this);
t->SetTool(olive::core.tool());
t->SetSnapping(olive::core.snapping());
t->SetTool(Core::instance()->tool());
t->SetSnapping(Core::instance()->snapping());
setWidget(t);
connect(t, SIGNAL(ToolChanged(const olive::tool::Tool&)), &olive::core, SLOT(SetTool(const olive::tool::Tool&)));
connect(&olive::core, SIGNAL(ToolChanged(const olive::tool::Tool&)), t, SLOT(SetTool(const olive::tool::Tool&)));
connect(t, SIGNAL(ToolChanged(const Tool::Item&)), Core::instance(), SLOT(SetTool(const Tool::Item&)));
connect(Core::instance(), SIGNAL(ToolChanged(const Tool::Item&)), t, SLOT(SetTool(const Tool::Item&)));
connect(t, SIGNAL(SnappingChanged(const bool&)), &olive::core, SLOT(SetSnapping(const bool&)));
connect(&olive::core, SIGNAL(SnappingChanged(const bool&)), t, SLOT(SetSnapping(const bool&)));
connect(t, SIGNAL(SnappingChanged(const bool&)), Core::instance(), SLOT(SetSnapping(const bool&)));
connect(Core::instance(), SIGNAL(SnappingChanged(const bool&)), t, SLOT(SetSnapping(const bool&)));
Retranslate();
}
+3 -4
View File
@@ -25,7 +25,6 @@
#include <QUrl>
#include "core.h"
#include "undo/undostack.h"
ProjectViewModel::ProjectViewModel(QObject *parent) :
QAbstractItemModel(parent),
@@ -197,7 +196,7 @@ bool ProjectViewModel::setData(const QModelIndex &index, const QVariant &value,
RenameItemCommand* ric = new RenameItemCommand(this, item, value.toString());
olive::undo_stack.push(ric);
Core::instance()->undo_stack()->push(ric);
return true;
}
@@ -338,7 +337,7 @@ bool ProjectViewModel::dropMimeData(const QMimeData *data, Qt::DropAction action
}
}
olive::undo_stack.pushIfHasChildren(move_command);
Core::instance()->undo_stack()->pushIfHasChildren(move_command);
return true;
@@ -368,7 +367,7 @@ bool ProjectViewModel::dropMimeData(const QMimeData *data, Qt::DropAction action
}
// Trigger an import
olive::core.ImportFiles(urls, this, static_cast<Folder*>(drop_item));
Core::instance()->ImportFiles(urls, this, static_cast<Folder*>(drop_item));
}
return false;
-12
View File
@@ -1,12 +0,0 @@
#ifndef PROJECTVIEWTYPE_H
#define PROJECTVIEWTYPE_H
namespace olive {
enum ProjectViewType {
TreeView,
ListView,
IconView
};
}
#endif // PROJECTVIEWTYPE_H
+2 -2
View File
@@ -117,8 +117,8 @@ void Exporter::FrameRendered(const rational &time, QVariant value)
FramePtr frame = TextureToFrame(value);
// OCIO conversion requires a frame in 32F format
if (frame->format() != olive::PIX_FMT_RGBA32F) {
frame = PixelService::ConvertPixelFormat(frame, olive::PIX_FMT_RGBA32F);
if (frame->format() != PixelFormat::PIX_FMT_RGBA32F) {
frame = PixelService::ConvertPixelFormat(frame, PixelFormat::PIX_FMT_RGBA32F);
}
// Color conversion must be done with unassociated alpha, and the pipeline is always associated
+2 -2
View File
@@ -16,8 +16,6 @@
set(OLIVE_SOURCES
${OLIVE_SOURCES}
render/backend/opengl/functions.h
render/backend/opengl/functions.cpp
render/backend/opengl/openglbackend.h
render/backend/opengl/openglbackend.cpp
render/backend/opengl/openglcolorprocessor.h
@@ -26,6 +24,8 @@ set(OLIVE_SOURCES
render/backend/opengl/openglexporter.cpp
render/backend/opengl/openglframebuffer.h
render/backend/opengl/openglframebuffer.cpp
render/backend/opengl/openglrenderfunctions.h
render/backend/opengl/openglrenderfunctions.cpp
render/backend/opengl/openglshader.h
render/backend/opengl/openglshader.cpp
render/backend/opengl/openglshadercache.h
+2 -2
View File
@@ -3,7 +3,7 @@
#include <QEventLoop>
#include <QThread>
#include "functions.h"
#include "openglrenderfunctions.h"
OpenGLBackend::OpenGLBackend(QObject *parent) :
VideoRenderBackend(parent),
@@ -168,7 +168,7 @@ OpenGLTexturePtr OpenGLBackend::CopyTexture(OpenGLTexturePtr input)
copy_buffer_.Bind();
input->Bind();
olive::gl::Blit(copy_pipeline_);
OpenGLRenderFunctions::Blit(copy_pipeline_);
input->Release();
copy_buffer_.Release();
@@ -3,7 +3,7 @@
#include <QOpenGLContext>
#include <QOpenGLFunctions>
#include "functions.h"
#include "openglrenderfunctions.h"
void OpenGLColorProcessor::Enable(QOpenGLContext *context, bool alpha_is_associated)
{
@@ -31,7 +31,7 @@ OpenGLShaderPtr OpenGLColorProcessor::pipeline() const
void OpenGLColorProcessor::ProcessOpenGL()
{
olive::gl::OCIOBlit(pipeline_, ocio_lut_);
OpenGLRenderFunctions::OCIOBlit(pipeline_, ocio_lut_);
}
OpenGLColorProcessor::OpenGLColorProcessor(OCIO::ConstConfigRcPtr config, const QString &source_space, const QString &dest_space) :
+3 -3
View File
@@ -1,6 +1,6 @@
#include "openglexporter.h"
#include "render/backend/opengl/functions.h"
#include "render/backend/opengl/openglrenderfunctions.h"
#include "render/pixelservice.h"
OpenGLExporter::OpenGLExporter(ViewerOutput* viewer, const VideoRenderingParams& video_params, const AudioRenderingParams &audio_params, const QMatrix4x4 &transform, ColorProcessorPtr color_processor, Encoder *encoder, QObject* parent) :
@@ -55,7 +55,7 @@ FramePtr OpenGLExporter::TextureToFrame(const QVariant& texture)
buffer_.Bind();
input_tex->Bind();
olive::gl::Blit(pipeline_, false, transform_);
OpenGLRenderFunctions::Blit(pipeline_, false, transform_);
input_tex->Release();
buffer_.Release();
@@ -65,7 +65,7 @@ FramePtr OpenGLExporter::TextureToFrame(const QVariant& texture)
buffer_.Attach(texture_);
buffer_.Bind();
PixelFormatInfo format_info = PixelService::GetPixelFormatInfo(video_params_.format());
PixelFormat::Info format_info = PixelService::GetPixelFormatInfo(video_params_.format());
f->glReadPixels(0,
0,
@@ -18,7 +18,7 @@
***/
#include "functions.h"
#include "openglrenderfunctions.h"
#include <QOpenGLExtraFunctions>
#include <QOpenGLVertexArrayObject>
@@ -63,7 +63,7 @@ const GLfloat flipped_blit_texcoords[] = {
*
* Currently active QOpenGLFunctions object (use context()->functions() if unsure).
*/
void olive::gl::PrepareToDraw(QOpenGLFunctions* f) {
void OpenGLRenderFunctions::PrepareToDraw(QOpenGLFunctions* f) {
f->glGenerateMipmap(GL_TEXTURE_2D);
f->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
f->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
@@ -71,7 +71,7 @@ void olive::gl::PrepareToDraw(QOpenGLFunctions* f) {
f->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
}
void olive::gl::Blit(OpenGLShaderPtr pipeline, bool flipped, QMatrix4x4 matrix) {
void OpenGLRenderFunctions::Blit(OpenGLShaderPtr pipeline, bool flipped, QMatrix4x4 matrix) {
// FIXME: is currentContext() reliable here?
QOpenGLFunctions* func = QOpenGLContext::currentContext()->functions();
@@ -123,7 +123,7 @@ void olive::gl::Blit(OpenGLShaderPtr pipeline, bool flipped, QMatrix4x4 matrix)
func->glFinish();
}
void olive::gl::OCIOBlit(OpenGLShaderPtr pipeline,
void OpenGLRenderFunctions::OCIOBlit(OpenGLShaderPtr pipeline,
GLuint lut,
bool flipped,
QMatrix4x4 matrix)
@@ -139,7 +139,7 @@ void olive::gl::OCIOBlit(OpenGLShaderPtr pipeline,
pipeline->setUniformValue("ove_ociolut", 2);
olive::gl::Blit(pipeline, flipped, matrix);
OpenGLRenderFunctions::Blit(pipeline, flipped, matrix);
pipeline->release();
@@ -26,31 +26,28 @@
#include "openglshader.h"
namespace olive {
namespace gl {
class OpenGLRenderFunctions {
public:
/**
* @brief Draw texture on screen
*
* @param pipeline
*
* Shader to use for the texture drawing
*
* @param flipped
*
* Draw the texture vertically flipped (defaults to FALSE)
*
* @param matrix
*
* Transformation matrix to use when drawing (defaults to no transform)
*/
static void Blit(OpenGLShaderPtr pipeline, bool flipped = false, QMatrix4x4 matrix = QMatrix4x4());
/**
* @brief Draw texture on screen
*
* @param pipeline
*
* Shader to use for the texture drawing
*
* @param flipped
*
* Draw the texture vertically flipped (defaults to FALSE)
*
* @param matrix
*
* Transformation matrix to use when drawing (defaults to no transform)
*/
void Blit(OpenGLShaderPtr pipeline, bool flipped = false, QMatrix4x4 matrix = QMatrix4x4());
static void OCIOBlit(OpenGLShaderPtr pipeline, GLuint lut, bool flipped = false, QMatrix4x4 matrix = QMatrix4x4());
void OCIOBlit(OpenGLShaderPtr pipeline, GLuint lut, bool flipped = false, QMatrix4x4 matrix = QMatrix4x4());
void PrepareToDraw(QOpenGLFunctions* f);
}
}
static void PrepareToDraw(QOpenGLFunctions* f);
};
#endif // OPENGLFUNCTIONS_H
+5 -5
View File
@@ -30,7 +30,7 @@ OpenGLTexture::OpenGLTexture() :
texture_(0),
width_(0),
height_(0),
format_(olive::PIX_FMT_INVALID)
format_(PixelFormat::PIX_FMT_INVALID)
{
}
@@ -44,7 +44,7 @@ bool OpenGLTexture::IsCreated() const
return (texture_);
}
void OpenGLTexture::Create(QOpenGLContext *ctx, int width, int height, const olive::PixelFormat &format, const void* data)
void OpenGLTexture::Create(QOpenGLContext *ctx, int width, int height, const PixelFormat::Format &format, const void* data)
{
if (!ctx) {
qWarning() << "OpenGLTexture::Create was passed an invalid context";
@@ -115,7 +115,7 @@ const int &OpenGLTexture::height() const
return height_;
}
const olive::PixelFormat &OpenGLTexture::format() const
const PixelFormat::Format &OpenGLTexture::format() const
{
return format_;
}
@@ -141,7 +141,7 @@ void OpenGLTexture::Upload(const void *data)
Bind();
PixelFormatInfo info = PixelService::GetPixelFormatInfo(format_);
PixelFormat::Info info = PixelService::GetPixelFormatInfo(format_);
context->functions()->glTexSubImage2D(GL_TEXTURE_2D,
0,
@@ -173,7 +173,7 @@ void OpenGLTexture::CreateInternal(QOpenGLContext* create_ctx, GLuint* tex, cons
f->glBindTexture(GL_TEXTURE_2D, *tex);
// Allocate storage for texture
const PixelFormatInfo& bit_depth = PixelService::GetPixelFormatInfo(format_);
const PixelFormat::Info& bit_depth = PixelService::GetPixelFormatInfo(format_);
f->glTexImage2D(
GL_TEXTURE_2D,
+3 -3
View File
@@ -40,7 +40,7 @@ public:
DISABLE_COPY_MOVE(OpenGLTexture)
void Create(QOpenGLContext* ctx, int width, int height, const olive::PixelFormat &format, const void *data = nullptr);
void Create(QOpenGLContext* ctx, int width, int height, const PixelFormat::Format &format, const void *data = nullptr);
void Create(QOpenGLContext* ctx, FramePtr frame);
bool IsCreated() const;
@@ -53,7 +53,7 @@ public:
const int& height() const;
const olive::PixelFormat &format() const;
const PixelFormat::Format &format() const;
const GLuint& texture() const;
@@ -73,7 +73,7 @@ private:
int height_;
olive::PixelFormat format_;
PixelFormat::Format format_;
};
+7 -7
View File
@@ -2,10 +2,10 @@
#include "common/clamp.h"
#include "core.h"
#include "functions.h"
#include "node/block/transition/transition.h"
#include "node/node.h"
#include "openglcolorprocessor.h"
#include "openglrenderfunctions.h"
#include "render/colormanager.h"
#include "render/pixelservice.h"
@@ -72,14 +72,14 @@ void OpenGLWorker::FrameToValue(StreamPtr stream, FramePtr frame, NodeValueTable
}
// OCIO's CPU conversion is more accurate, so for online we render on CPU but offline we render GPU
if (video_params().mode() == olive::kOnline) {
if (video_params().mode() == RenderMode::kOnline) {
// If alpha is associated, disassociate for the color transform
if (video_stream->premultiplied_alpha()) {
ColorManager::DisassociateAlpha(frame);
}
// Convert frame to float for OCIO
frame = PixelService::ConvertPixelFormat(frame, olive::PIX_FMT_RGBA32F);
frame = PixelService::ConvertPixelFormat(frame, PixelFormat::PIX_FMT_RGBA32F);
// Perform color transform
color_processor->ConvertFrame(frame);
@@ -96,7 +96,7 @@ void OpenGLWorker::FrameToValue(StreamPtr stream, FramePtr frame, NodeValueTable
OpenGLTextureCache::ReferencePtr footage_tex_ref = texture_cache_->Get(ctx_, footage_params, frame->data());
if (video_params().mode() == olive::kOffline) {
if (video_params().mode() == RenderMode::kOffline) {
if (!color_processor->IsEnabled()) {
color_processor->Enable(ctx_, video_stream->premultiplied_alpha());
}
@@ -238,7 +238,7 @@ void OpenGLWorker::RunNodeAccelerated(const Node *node, const TimeRange &range,
iterative_input = input_texture_count;
}
olive::gl::PrepareToDraw(functions_);
OpenGLRenderFunctions::PrepareToDraw(functions_);
input_texture_count++;
break;
@@ -322,7 +322,7 @@ void OpenGLWorker::RunNodeAccelerated(const Node *node, const TimeRange &range,
buffer_.Bind();
// Blit this texture through this shader
olive::gl::Blit(shader);
OpenGLRenderFunctions::Blit(shader);
buffer_.Release();
buffer_.Detach();
@@ -353,7 +353,7 @@ void OpenGLWorker::TextureToBuffer(const QVariant &tex_in, QByteArray &buffer)
{
OpenGLTextureCache::ReferencePtr texture = tex_in.value<OpenGLTextureCache::ReferencePtr>();
PixelFormatInfo format_info = PixelService::GetPixelFormatInfo(video_params().format());
PixelFormat::Info format_info = PixelService::GetPixelFormatInfo(video_params().format());
QOpenGLFunctions* f = QOpenGLContext::currentContext()->functions();
buffer_.Attach(texture->texture());
+1 -1
View File
@@ -136,7 +136,7 @@ void VideoRenderWorker::CloseInternal()
void VideoRenderWorker::Download(NodeDependency dep, QByteArray hash, QVariant texture, QString filename)
{
PixelFormatInfo format_info = PixelService::GetPixelFormatInfo(video_params().format());
PixelFormat::Info format_info = PixelService::GetPixelFormatInfo(video_params().format());
// Set up OIIO::ImageSpec for compressing cached images on disk
OIIO::ImageSpec spec(video_params().effective_width(), video_params().effective_height(), kRGBAChannels, format_info.oiio_desc);
+7 -7
View File
@@ -114,21 +114,21 @@ void ColorManager::AssociateAlphaPixFmtFilter(ColorManager::AlphaAction action,
{
int pixel_count = f->width() * f->height() * kRGBAChannels;
switch (static_cast<olive::PixelFormat>(f->format())) {
case olive::PIX_FMT_INVALID:
case olive::PIX_FMT_COUNT:
switch (static_cast<PixelFormat::Format>(f->format())) {
case PixelFormat::PIX_FMT_INVALID:
case PixelFormat::PIX_FMT_COUNT:
qWarning() << "Alpha association functions received an invalid pixel format";
break;
case olive::PIX_FMT_RGBA8:
case olive::PIX_FMT_RGBA16U:
case PixelFormat::PIX_FMT_RGBA8:
case PixelFormat::PIX_FMT_RGBA16U:
qWarning() << "Alpha association functions only works on float-based pixel formats at this time";
break;
case olive::PIX_FMT_RGBA16F:
case PixelFormat::PIX_FMT_RGBA16F:
{
AssociateAlphaInternal<qfloat16>(action, reinterpret_cast<qfloat16*>(f->data()), pixel_count);
break;
}
case olive::PIX_FMT_RGBA32F:
case PixelFormat::PIX_FMT_RGBA32F:
{
AssociateAlphaInternal<float>(action, reinterpret_cast<float*>(f->data()), pixel_count);
break;
+35 -13
View File
@@ -21,22 +21,44 @@
#ifndef BITDEPTHS_H
#define BITDEPTHS_H
namespace olive {
#include <OpenImageIO/imageio.h>
#include <QOpenGLExtraFunctions>
#include <QString>
/**
* @brief Olive's internal supported pixel formats.
*/
enum PixelFormat {
PIX_FMT_INVALID = -1,
class PixelFormat {
public:
/**
* @brief Olive's internal supported pixel formats.
*/
enum Format {
PIX_FMT_INVALID = -1,
PIX_FMT_RGBA8,
PIX_FMT_RGBA16U,
PIX_FMT_RGBA16F,
PIX_FMT_RGBA32F,
PIX_FMT_RGBA8,
PIX_FMT_RGBA16U,
PIX_FMT_RGBA16F,
PIX_FMT_RGBA32F,
PIX_FMT_COUNT
PIX_FMT_COUNT
};
/**
* @brief A struct of information pertaining to each enum PixelFormat.
*
* Primarily this is a means of retrieving OpenGL texture information for different pixel formats/bit depths. Both
* RAM and VRAM buffers will need a PixelFormat. To keep consistency between the OpenGL code and CPU code when using
* a given PixelFormat, the PixelFormatInfo struct contains all necessary variables that you'll need to plug into
* OpenGL.
*
* Use the static function PixelService::GetPixelFormatInfo to generate a PixelFormatInfo object.
*/
struct Info {
QString name;
GLint internal_format;
GLenum pixel_format;
GLenum gl_pixel_type;
int bytes_per_pixel;
OIIO::TypeDesc oiio_desc;
};
};
}
#endif // BITDEPTHS_H
+56 -56
View File
@@ -30,37 +30,37 @@ PixelService::PixelService()
{
}
PixelFormatInfo PixelService::GetPixelFormatInfo(const olive::PixelFormat &format)
PixelFormat::Info PixelService::GetPixelFormatInfo(const PixelFormat::Format &format)
{
PixelFormatInfo info;
PixelFormat::Info info;
switch (format) {
case olive::PIX_FMT_RGBA8:
case PixelFormat::PIX_FMT_RGBA8:
info.name = tr("8-bit");
info.internal_format = GL_RGBA8;
info.gl_pixel_type = GL_UNSIGNED_BYTE;
info.oiio_desc = OIIO::TypeDesc::UINT8;
break;
case olive::PIX_FMT_RGBA16U:
case PixelFormat::PIX_FMT_RGBA16U:
info.name = tr("16-bit Integer");
info.internal_format = GL_RGBA16;
info.gl_pixel_type = GL_UNSIGNED_SHORT;
info.oiio_desc = OIIO::TypeDesc::UINT16;
break;
case olive::PIX_FMT_RGBA16F:
case PixelFormat::PIX_FMT_RGBA16F:
info.name = tr("Half-Float (16-bit)");
info.internal_format = GL_RGBA16F;
info.gl_pixel_type = GL_HALF_FLOAT;
info.oiio_desc = OIIO::TypeDesc::HALF;
break;
case olive::PIX_FMT_RGBA32F:
case PixelFormat::PIX_FMT_RGBA32F:
info.name = tr("Full-Float (32-bit)");
info.internal_format = GL_RGBA32F;
info.gl_pixel_type = GL_FLOAT;
info.oiio_desc = OIIO::TypeDesc::FLOAT;
break;
case olive::PIX_FMT_INVALID:
case olive::PIX_FMT_COUNT:
case PixelFormat::PIX_FMT_INVALID:
case PixelFormat::PIX_FMT_COUNT:
qFatal("Invalid pixel format requested");
}
@@ -70,28 +70,28 @@ PixelFormatInfo PixelService::GetPixelFormatInfo(const olive::PixelFormat &forma
return info;
}
int PixelService::GetBufferSize(const olive::PixelFormat &format, const int &width, const int &height)
int PixelService::GetBufferSize(const PixelFormat::Format &format, const int &width, const int &height)
{
return BytesPerPixel(format) * width * height;
}
int PixelService::BytesPerPixel(const olive::PixelFormat &format)
int PixelService::BytesPerPixel(const PixelFormat::Format &format)
{
return BytesPerChannel(format) * kRGBAChannels;
}
int PixelService::BytesPerChannel(const olive::PixelFormat &format)
int PixelService::BytesPerChannel(const PixelFormat::Format &format)
{
switch (format) {
case olive::PIX_FMT_RGBA8:
case PixelFormat::PIX_FMT_RGBA8:
return 1;
case olive::PIX_FMT_RGBA16U:
case olive::PIX_FMT_RGBA16F:
case PixelFormat::PIX_FMT_RGBA16U:
case PixelFormat::PIX_FMT_RGBA16F:
return 2;
case olive::PIX_FMT_RGBA32F:
case PixelFormat::PIX_FMT_RGBA32F:
return 4;
case olive::PIX_FMT_INVALID:
case olive::PIX_FMT_COUNT:
case PixelFormat::PIX_FMT_INVALID:
case PixelFormat::PIX_FMT_COUNT:
break;
}
@@ -101,7 +101,7 @@ int PixelService::BytesPerChannel(const olive::PixelFormat &format)
return 0;
}
FramePtr PixelService::ConvertPixelFormat(FramePtr frame, const olive::PixelFormat &dest_format)
FramePtr PixelService::ConvertPixelFormat(FramePtr frame, const PixelFormat::Format &dest_format)
{
if (frame->format() == dest_format) {
return frame;
@@ -122,13 +122,13 @@ FramePtr PixelService::ConvertPixelFormat(FramePtr frame, const olive::PixelForm
bool valid = true;
switch (static_cast<olive::PixelFormat>(frame->format())) {
case olive::PIX_FMT_RGBA8:
switch (static_cast<PixelFormat::Format>(frame->format())) {
case PixelFormat::PIX_FMT_RGBA8:
{
uint8_t* source = reinterpret_cast<uint8_t*>(frame->data());
switch (dest_format) {
case olive::PIX_FMT_RGBA16U: // 8-bit Integer -> 16-bit Integer
case PixelFormat::PIX_FMT_RGBA16U: // 8-bit Integer -> 16-bit Integer
{
uint16_t* destination = reinterpret_cast<uint16_t*>(converted->data());
for (int i=0;i<pix_count;i++) {
@@ -136,7 +136,7 @@ FramePtr PixelService::ConvertPixelFormat(FramePtr frame, const olive::PixelForm
}
break;
}
case olive::PIX_FMT_RGBA16F: // 8-bit Integer -> 16-bit Float
case PixelFormat::PIX_FMT_RGBA16F: // 8-bit Integer -> 16-bit Float
{
qfloat16* destination = reinterpret_cast<qfloat16*>(converted->data());
for (int i=0;i<pix_count;i++) {
@@ -144,7 +144,7 @@ FramePtr PixelService::ConvertPixelFormat(FramePtr frame, const olive::PixelForm
}
break;
}
case olive::PIX_FMT_RGBA32F: // 8-bit Integer -> 32-bit Float
case PixelFormat::PIX_FMT_RGBA32F: // 8-bit Integer -> 32-bit Float
{
float* destination = reinterpret_cast<float*>(converted->data());
for (int i=0;i<pix_count;i++) {
@@ -152,19 +152,19 @@ FramePtr PixelService::ConvertPixelFormat(FramePtr frame, const olive::PixelForm
}
break;
}
case olive::PIX_FMT_INVALID:
case olive::PIX_FMT_RGBA8:
case olive::PIX_FMT_COUNT:
case PixelFormat::PIX_FMT_INVALID:
case PixelFormat::PIX_FMT_RGBA8:
case PixelFormat::PIX_FMT_COUNT:
valid = false;
}
break;
}
case olive::PIX_FMT_RGBA16U:
case PixelFormat::PIX_FMT_RGBA16U:
{
uint16_t* source = reinterpret_cast<uint16_t*>(frame->data());
switch (dest_format) {
case olive::PIX_FMT_RGBA8: // 16-bit Integer -> 8-bit Integer
case PixelFormat::PIX_FMT_RGBA8: // 16-bit Integer -> 8-bit Integer
{
uint8_t* destination = reinterpret_cast<uint8_t*>(converted->data());
for (int i=0;i<pix_count;i++) {
@@ -172,7 +172,7 @@ FramePtr PixelService::ConvertPixelFormat(FramePtr frame, const olive::PixelForm
}
break;
}
case olive::PIX_FMT_RGBA16F: // 16-bit Integer -> 16-bit Float
case PixelFormat::PIX_FMT_RGBA16F: // 16-bit Integer -> 16-bit Float
{
qfloat16* destination = reinterpret_cast<qfloat16*>(converted->data());
for (int i=0;i<pix_count;i++) {
@@ -180,7 +180,7 @@ FramePtr PixelService::ConvertPixelFormat(FramePtr frame, const olive::PixelForm
}
break;
}
case olive::PIX_FMT_RGBA32F: // 16-bit Integer -> 32-bit Float
case PixelFormat::PIX_FMT_RGBA32F: // 16-bit Integer -> 32-bit Float
{
float* destination = reinterpret_cast<float*>(converted->data());
for (int i=0;i<pix_count;i++) {
@@ -188,19 +188,19 @@ FramePtr PixelService::ConvertPixelFormat(FramePtr frame, const olive::PixelForm
}
break;
}
case olive::PIX_FMT_INVALID:
case olive::PIX_FMT_RGBA16U:
case olive::PIX_FMT_COUNT:
case PixelFormat::PIX_FMT_INVALID:
case PixelFormat::PIX_FMT_RGBA16U:
case PixelFormat::PIX_FMT_COUNT:
valid = false;
}
break;
}
case olive::PIX_FMT_RGBA16F:
case PixelFormat::PIX_FMT_RGBA16F:
{
qfloat16* source = reinterpret_cast<qfloat16*>(frame->data());
switch (dest_format) {
case olive::PIX_FMT_RGBA8: // 16-bit Float -> 8-bit Integer
case PixelFormat::PIX_FMT_RGBA8: // 16-bit Float -> 8-bit Integer
{
uint8_t* destination = reinterpret_cast<uint8_t*>(converted->data());
for (int i=0;i<pix_count;i++) {
@@ -208,7 +208,7 @@ FramePtr PixelService::ConvertPixelFormat(FramePtr frame, const olive::PixelForm
}
break;
}
case olive::PIX_FMT_RGBA16U: // 16-bit Float -> 16-bit Integer
case PixelFormat::PIX_FMT_RGBA16U: // 16-bit Float -> 16-bit Integer
{
uint16_t* destination = reinterpret_cast<uint16_t*>(converted->data());
for (int i=0;i<pix_count;i++) {
@@ -216,7 +216,7 @@ FramePtr PixelService::ConvertPixelFormat(FramePtr frame, const olive::PixelForm
}
break;
}
case olive::PIX_FMT_RGBA32F: // 16-bit Float -> 32-bit Float
case PixelFormat::PIX_FMT_RGBA32F: // 16-bit Float -> 32-bit Float
{
float* destination = reinterpret_cast<float*>(converted->data());
for (int i=0;i<pix_count;i++) {
@@ -224,19 +224,19 @@ FramePtr PixelService::ConvertPixelFormat(FramePtr frame, const olive::PixelForm
}
break;
}
case olive::PIX_FMT_INVALID:
case olive::PIX_FMT_RGBA16F:
case olive::PIX_FMT_COUNT:
case PixelFormat::PIX_FMT_INVALID:
case PixelFormat::PIX_FMT_RGBA16F:
case PixelFormat::PIX_FMT_COUNT:
valid = false;
}
break;
}
case olive::PIX_FMT_RGBA32F:
case PixelFormat::PIX_FMT_RGBA32F:
{
float* source = reinterpret_cast<float*>(frame->data());
switch (dest_format) {
case olive::PIX_FMT_RGBA8: // 32-bit Float -> 8-bit Integer
case PixelFormat::PIX_FMT_RGBA8: // 32-bit Float -> 8-bit Integer
{
uint8_t* destination = reinterpret_cast<uint8_t*>(converted->data());
for (int i=0;i<pix_count;i++) {
@@ -244,7 +244,7 @@ FramePtr PixelService::ConvertPixelFormat(FramePtr frame, const olive::PixelForm
}
break;
}
case olive::PIX_FMT_RGBA16U: // 32-bit Float -> 16-bit Integer
case PixelFormat::PIX_FMT_RGBA16U: // 32-bit Float -> 16-bit Integer
{
uint16_t* destination = reinterpret_cast<uint16_t*>(converted->data());
for (int i=0;i<pix_count;i++) {
@@ -252,7 +252,7 @@ FramePtr PixelService::ConvertPixelFormat(FramePtr frame, const olive::PixelForm
}
break;
}
case olive::PIX_FMT_RGBA16F: // 32-bit Float -> 16-bit Float
case PixelFormat::PIX_FMT_RGBA16F: // 32-bit Float -> 16-bit Float
{
qfloat16* destination = reinterpret_cast<qfloat16*>(converted->data());
for (int i=0;i<pix_count;i++) {
@@ -260,15 +260,15 @@ FramePtr PixelService::ConvertPixelFormat(FramePtr frame, const olive::PixelForm
}
break;
}
case olive::PIX_FMT_INVALID:
case olive::PIX_FMT_RGBA32F:
case olive::PIX_FMT_COUNT:
case PixelFormat::PIX_FMT_INVALID:
case PixelFormat::PIX_FMT_RGBA32F:
case PixelFormat::PIX_FMT_COUNT:
valid = false;
}
break;
}
case olive::PIX_FMT_INVALID:
case olive::PIX_FMT_COUNT:
case PixelFormat::PIX_FMT_INVALID:
case PixelFormat::PIX_FMT_COUNT:
valid = false;
}
@@ -282,7 +282,7 @@ FramePtr PixelService::ConvertPixelFormat(FramePtr frame, const olive::PixelForm
void PixelService::ConvertRGBtoRGBA(FramePtr frame)
{
olive::PixelFormat dest_format = static_cast<olive::PixelFormat>(frame->format());
PixelFormat::Format dest_format = static_cast<PixelFormat::Format>(frame->format());
int rgb_pixel_size = BytesPerChannel(dest_format) * kRGBChannels;
int rgb_frame_size = frame->width() * frame->height() * rgb_pixel_size;
@@ -300,20 +300,20 @@ void PixelService::ConvertRGBtoRGBA(FramePtr frame)
// Write a full alpha value according to the format
switch (dest_format) {
case olive::PIX_FMT_RGBA8:
case PixelFormat::PIX_FMT_RGBA8:
*alpha_ptr = UINT8_MAX;
break;
case olive::PIX_FMT_RGBA16U:
case PixelFormat::PIX_FMT_RGBA16U:
*reinterpret_cast<uint16_t*>(alpha_ptr) = UINT16_MAX;
break;
case olive::PIX_FMT_RGBA16F:
case PixelFormat::PIX_FMT_RGBA16F:
*reinterpret_cast<qfloat16*>(alpha_ptr) = 1.0f;
break;
case olive::PIX_FMT_RGBA32F:
case PixelFormat::PIX_FMT_RGBA32F:
*reinterpret_cast<float*>(alpha_ptr) = 1.0f;
break;
case olive::PIX_FMT_INVALID:
case olive::PIX_FMT_COUNT:
case PixelFormat::PIX_FMT_INVALID:
case PixelFormat::PIX_FMT_COUNT:
qFatal("Invalid pixel format requested");
}
+5 -26
View File
@@ -22,31 +22,10 @@
#define PIXELSERVICE_H
#include <QString>
#include <QOpenGLExtraFunctions>
#include <OpenImageIO/imageio.h>
#include "codec/frame.h"
#include "pixelformat.h"
/**
* @brief A struct of information pertaining to each enum PixelFormat.
*
* Primarily this is a means of retrieving OpenGL texture information for different pixel formats/bit depths. Both
* RAM and VRAM buffers will need a PixelFormat. To keep consistency between the OpenGL code and CPU code when using
* a given PixelFormat, the PixelFormatInfo struct contains all necessary variables that you'll need to plug into
* OpenGL.
*
* Use the static function PixelService::GetPixelFormatInfo to generate a PixelFormatInfo object.
*/
struct PixelFormatInfo {
QString name;
GLint internal_format;
GLenum pixel_format;
GLenum gl_pixel_type;
int bytes_per_pixel;
OIIO::TypeDesc oiio_desc;
};
class PixelService : public QObject {
public:
@@ -57,7 +36,7 @@ public:
*
* \see PixelFormatInfo
*/
static PixelFormatInfo GetPixelFormatInfo(const olive::PixelFormat& format);
static PixelFormat::Info GetPixelFormatInfo(const PixelFormat::Format& format);
/**
* @brief Returns the minimum buffer size (in bytes) necessary for a given format, width, and height.
@@ -74,7 +53,7 @@ public:
*
* The height (in pixels) of the buffer.
*/
static int GetBufferSize(const olive::PixelFormat &format, const int& width, const int& height);
static int GetBufferSize(const PixelFormat::Format &format, const int& width, const int& height);
/**
* @brief Returns the number of bytes per pixel for a certain format
@@ -83,19 +62,19 @@ public:
* requires for a certain format. The number of bytes will always be a multiple of 4 since all formats use RGBA and
* are at least 1 bpc.
*/
static int BytesPerPixel(const olive::PixelFormat& format);
static int BytesPerPixel(const PixelFormat::Format &format);
/**
* @brief Returns the number of bytes per channel for a certain format
*/
static int BytesPerChannel(const olive::PixelFormat& format);
static int BytesPerChannel(const PixelFormat::Format& format);
/**
* @brief Convert a frame to a pixel format
*
* If the frame's pixel format == the destination format, this just returns `frame`.
*/
static FramePtr ConvertPixelFormat(FramePtr frame, const olive::PixelFormat &dest_format);
static FramePtr ConvertPixelFormat(FramePtr frame, const PixelFormat::Format &dest_format);
/**
* @brief Convert an RGB image to an RGBA image
+15 -16
View File
@@ -1,25 +1,24 @@
#ifndef RENDERMODE_H
#define RENDERMODE_H
namespace olive {
/**
* @brief The primary different "modes" the renderer can function in
*/
enum RenderMode {
class RenderMode {
public:
/**
* This render is for realtime preview ONLY and does not need to be "perfect". Nodes can use lower-accuracy functions
* to save performance when possible.
* @brief The primary different "modes" the renderer can function in
*/
kOffline,
enum Mode {
/**
* This render is for realtime preview ONLY and does not need to be "perfect". Nodes can use lower-accuracy functions
* to save performance when possible.
*/
kOffline,
/**
* This render is some sort of export or master copy and Nodes should take time/bandwidth/system resources to produce
* a higher accuracy version.
*/
kOnline
/**
* This render is some sort of export or master copy and Nodes should take time/bandwidth/system resources to produce
* a higher accuracy version.
*/
kOnline
};
};
}
#endif // RENDERMODE_H
+7 -7
View File
@@ -30,11 +30,11 @@ const rational &VideoParams::time_base() const
}
VideoRenderingParams::VideoRenderingParams() :
format_(olive::PIX_FMT_INVALID)
format_(PixelFormat::PIX_FMT_INVALID)
{
}
VideoRenderingParams::VideoRenderingParams(const int &width, const int &height, const rational &time_base, const olive::PixelFormat &format, const olive::RenderMode& mode, const int &divider) :
VideoRenderingParams::VideoRenderingParams(const int &width, const int &height, const rational &time_base, const PixelFormat::Format &format, const RenderMode::Mode& mode, const int &divider) :
VideoParams(width, height, time_base),
format_(format),
mode_(mode),
@@ -43,7 +43,7 @@ VideoRenderingParams::VideoRenderingParams(const int &width, const int &height,
calculate_effective_size();
}
VideoRenderingParams::VideoRenderingParams(const VideoParams &params, const olive::PixelFormat &format, const olive::RenderMode& mode, const int& divider) :
VideoRenderingParams::VideoRenderingParams(const VideoParams &params, const PixelFormat::Format &format, const RenderMode::Mode& mode, const int& divider) :
VideoParams(params),
format_(format),
mode_(mode),
@@ -67,12 +67,12 @@ const int& VideoRenderingParams::effective_height() const
return effective_height_;
}
const olive::PixelFormat &VideoRenderingParams::format() const
const PixelFormat::Format &VideoRenderingParams::format() const
{
return format_;
}
const olive::RenderMode &VideoRenderingParams::mode() const
const RenderMode::Mode &VideoRenderingParams::mode() const
{
return mode_;
}
@@ -88,6 +88,6 @@ bool VideoRenderingParams::is_valid() const
return (width() > 0
&& height() > 0
&& !time_base().isNull()
&& format_ != olive::PIX_FMT_INVALID
&& format_ != olive::PIX_FMT_COUNT);
&& format_ != PixelFormat::PIX_FMT_INVALID
&& format_ != PixelFormat::PIX_FMT_COUNT);
}
+6 -6
View File
@@ -25,22 +25,22 @@ private:
class VideoRenderingParams : public VideoParams {
public:
VideoRenderingParams();
VideoRenderingParams(const int& width, const int& height, const rational& time_base, const olive::PixelFormat& format, const olive::RenderMode& mode, const int& divider = 1);
VideoRenderingParams(const VideoParams& params, const olive::PixelFormat& format, const olive::RenderMode& mode, const int& divider = 1);
VideoRenderingParams(const int& width, const int& height, const rational& time_base, const PixelFormat::Format& format, const RenderMode::Mode& mode, const int& divider = 1);
VideoRenderingParams(const VideoParams& params, const PixelFormat::Format& format, const RenderMode::Mode& mode, const int& divider = 1);
const int& divider() const;
const int& effective_width() const;
const int& effective_height() const;
bool is_valid() const;
const olive::PixelFormat& format() const;
const olive::RenderMode& mode() const;
const PixelFormat::Format& format() const;
const RenderMode::Mode& mode() const;
private:
void calculate_effective_size();
olive::PixelFormat format_;
olive::RenderMode mode_;
PixelFormat::Format format_;
RenderMode::Mode mode_;
int divider_;
int effective_width_;
+2 -2
View File
@@ -31,10 +31,10 @@
#include "panel/project/project.h"
// End test code
#include "core.h"
#include "project/item/footage/footage.h"
#include "task/probe/probe.h"
#include "task/taskmanager.h"
#include "undo/undostack.h"
ImportTask::ImportTask(ProjectViewModel *model, Folder *parent, const QStringList &urls) :
model_(model),
@@ -67,7 +67,7 @@ bool ImportTask::Action()
bool ImportTask::Epilogue()
{
if (command_ != nullptr) {
olive::undo_stack.push(command_);
Core::instance()->undo_stack()->push(command_);
}
parent_->UnlockDeletes();
+8 -3
View File
@@ -23,7 +23,7 @@
#include <QDebug>
#include <QThread>
TaskManager olive::task_manager;
TaskManager TaskManager::instance_;
TaskManager::TaskManager()
{
@@ -35,6 +35,11 @@ TaskManager::~TaskManager()
Clear();
}
TaskManager *TaskManager::instance()
{
return &instance_;
}
void TaskManager::AddTask(TaskPtr t)
{
// Connect Task's status signal to the Callback
@@ -125,12 +130,12 @@ TaskManager::AddTaskCommand::AddTaskCommand(TaskPtr t, QUndoCommand *parent) :
void TaskManager::AddTaskCommand::redo()
{
olive::task_manager.AddTask(task_);
TaskManager::instance()->AddTask(task_);
}
void TaskManager::AddTaskCommand::undo()
{
olive::task_manager.DeleteTask(task_.get());
TaskManager::instance()->DeleteTask(task_.get());
task_->ResetState();
}
+7 -4
View File
@@ -70,6 +70,8 @@ public:
*/
TaskManager& operator=(TaskManager&& other) = delete;
static TaskManager* instance();
/**
* @brief Add a new Task
*
@@ -165,6 +167,11 @@ private:
*/
int maximum_task_count_;
/**
* @brief TaskManager singleton instance
*/
static TaskManager instance_;
private slots:
/**
* @brief Callback when a Task's status changes
@@ -180,8 +187,4 @@ private slots:
};
namespace olive {
extern TaskManager task_manager;
}
#endif // TASKMANAGER_H
+1 -3
View File
@@ -20,9 +20,7 @@
#include "undostack.h"
OliveUndoStack olive::undo_stack;
void OliveUndoStack::pushIfHasChildren(QUndoCommand *command)
void UndoStack::pushIfHasChildren(QUndoCommand *command)
{
if (command->childCount() > 0) {
push(command);
+1 -8
View File
@@ -23,7 +23,7 @@
#include <QUndoStack>
class OliveUndoStack : public QUndoStack {
class UndoStack : public QUndoStack {
public:
/**
* @brief A wrapper for push() that either pushes if the command has children or deletes if not
@@ -33,11 +33,4 @@ public:
void pushIfHasChildren(QUndoCommand* command);
};
namespace olive {
/**
* @brief A static undo stack for undoable commands throughout Olive
*/
extern OliveUndoStack undo_stack;
}
#endif // UNDOSTACK_H
+18 -7
View File
@@ -24,18 +24,14 @@
#include "panel/panelmanager.h"
#include "panel/timeline/timeline.h"
MenuShared olive::menu_shared;
MenuShared* MenuShared::instance_ = nullptr;
MenuShared::MenuShared()
{
}
void MenuShared::Initialize()
{
// "New" menu shared items
new_project_item_ = Menu::CreateItem(this, "newproj", nullptr, nullptr, "Ctrl+N");
new_sequence_item_ = Menu::CreateItem(this, "newseq", &olive::core, SLOT(CreateNewSequence()), "Ctrl+Shift+N");
new_folder_item_ = Menu::CreateItem(this, "newfolder", &olive::core, SLOT(CreateNewFolder()));
new_sequence_item_ = Menu::CreateItem(this, "newseq", Core::instance(), SLOT(CreateNewSequence()), "Ctrl+Shift+N");
new_folder_item_ = Menu::CreateItem(this, "newfolder", Core::instance(), SLOT(CreateNewFolder()));
// "Edit" menu shared items
edit_cut_item_ = Menu::CreateItem(this, "cut", nullptr, nullptr, "Ctrl+X");
@@ -63,6 +59,16 @@ void MenuShared::Initialize()
Retranslate();
}
void MenuShared::CreateInstance()
{
instance_ = new MenuShared();
}
void MenuShared::DestroyInstance()
{
delete instance_;
}
void MenuShared::AddItemsForNewMenu(Menu *m)
{
m->addAction(new_project_item_);
@@ -101,6 +107,11 @@ void MenuShared::AddItemsForClipEditMenu(Menu *m)
m->addAction(clip_nest_item_);
}
MenuShared *MenuShared::instance()
{
return instance_;
}
void MenuShared::SplitAtPlayhead()
{
TimelinePanel* timeline = PanelManager::instance()->MostRecentlyFocused<TimelinePanel>();
+7 -5
View File
@@ -31,7 +31,9 @@ class MenuShared : public QObject {
public:
MenuShared();
void Initialize();
static void CreateInstance();
static void DestroyInstance();
void Retranslate();
void AddItemsForNewMenu(Menu* m);
@@ -39,6 +41,8 @@ public:
void AddItemsForInOutMenu(Menu* m);
void AddItemsForClipEditMenu(Menu* m);
static MenuShared* instance();
private:
// "New" menu shared items
QAction* new_project_item_;
@@ -68,6 +72,8 @@ private:
QAction* clip_enable_disable_item_;
QAction* clip_nest_item_;
static MenuShared* instance_;
private slots:
void SplitAtPlayhead();
@@ -75,8 +81,4 @@ private slots:
};
namespace olive {
extern MenuShared menu_shared;
}
#endif // MENUSHARED_H
@@ -26,10 +26,10 @@
#include <QMessageBox>
#include <QPainter>
#include "core.h"
#include "nodeparamviewundo.h"
#include "project/item/sequence/sequence.h"
#include "ui/icons/icons.h"
#include "undo/undostack.h"
NodeParamViewItem::NodeParamViewItem(Node *node, QWidget *parent) :
QWidget(parent),
@@ -260,7 +260,7 @@ void NodeParamViewItem::UserChangedKeyframeEnable(bool e)
}
}
olive::undo_stack.pushIfHasChildren(command);
Core::instance()->undo_stack()->pushIfHasChildren(command);
}
void NodeParamViewItem::UserToggledKeyframe(bool e)
@@ -283,7 +283,7 @@ void NodeParamViewItem::UserToggledKeyframe(bool e)
new NodeParamRemoveKeyframeCommand(input, key, command);
}
olive::undo_stack.pushIfHasChildren(command);
Core::instance()->undo_stack()->pushIfHasChildren(command);
}
void NodeParamViewItem::InputKeyframeEnableChanged(bool e)
@@ -7,6 +7,7 @@
#include <QVector3D>
#include <QVector4D>
#include "core.h"
#include "node/node.h"
#include "nodeparamviewundo.h"
#include "project/item/sequence/sequence.h"
@@ -262,7 +263,7 @@ void NodeParamViewWidgetBridge::SetInputValue(const QVariant &value)
new NodeParamSetKeyframeValueCommand(input_->keyframes().first(), value, command);
}
olive::undo_stack.pushIfHasChildren(command);
Core::instance()->undo_stack()->pushIfHasChildren(command);
}
void NodeParamViewWidgetBridge::WidgetCallback()
+3 -3
View File
@@ -20,9 +20,9 @@
#include "nodeview.h"
#include "core.h"
#include "nodeviewundo.h"
#include "node/factory.h"
#include "undo/undostack.h"
NodeView::NodeView(QWidget *parent) :
QGraphicsView(parent),
@@ -142,7 +142,7 @@ void NodeView::DeleteSelected()
return;
}
olive::undo_stack.push(new NodeRemoveCommand(graph_, selected_nodes));
Core::instance()->undo_stack()->push(new NodeRemoveCommand(graph_, selected_nodes));
}
void NodeView::AddNode(Node* node)
@@ -244,6 +244,6 @@ void NodeView::CreateNodeSlot(QAction *action)
Node* new_node = NodeFactory::CreateFromMenuAction(action);
if (new_node) {
olive::undo_stack.push(new NodeAddCommand(graph_, new_node));
Core::instance()->undo_stack()->push(new NodeAddCommand(graph_, new_node));
}
}
+2 -3
View File
@@ -31,7 +31,6 @@
#include "nodeview.h"
#include "nodeviewundo.h"
#include "ui/icons/icons.h"
#include "undo/undostack.h"
#include "window/mainwindow/mainwindow.h"
NodeViewItem::NodeViewItem(QGraphicsItem *parent) :
@@ -169,7 +168,7 @@ void NodeViewItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *opti
{
// HACK for getting the main QWidget palette color (the `widget`'s palette uses the NodeView color instead which we
// don't want here)
QPalette app_pal = olive::core.main_window()->palette();
QPalette app_pal = Core::instance()->main_window()->palette();
// Set up border, which will change color if selected
QPen border_pen(css_proxy_.BorderColor(), node_border_width_);
@@ -460,7 +459,7 @@ void NodeViewItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
dragging_edge_ = nullptr;
olive::undo_stack.pushIfHasChildren(node_edge_change_command_);
Core::instance()->undo_stack()->pushIfHasChildren(node_edge_change_command_);
node_edge_change_command_ = nullptr;
return;
}
@@ -18,7 +18,6 @@ set(OLIVE_SOURCES
${OLIVE_SOURCES}
widget/projectexplorer/projectexplorer.h
widget/projectexplorer/projectexplorer.cpp
widget/projectexplorer/projectexplorerdefines.h
widget/projectexplorer/projectexplorertreeview.h
widget/projectexplorer/projectexplorertreeview.cpp
widget/projectexplorer/projectexplorerlistview.h
+15 -16
View File
@@ -24,12 +24,11 @@
#include <QMenu>
#include <QVBoxLayout>
#include "common/define.h"
#include "dialog/footageproperties/footageproperties.h"
#include "projectexplorerdefines.h"
ProjectExplorer::ProjectExplorer(QWidget *parent) :
QWidget(parent),
view_type_(olive::TreeView),
model_(this)
{
// Create layout
@@ -63,40 +62,40 @@ ProjectExplorer::ProjectExplorer(QWidget *parent) :
AddView(icon_view_);
// Set default view to tree view
set_view_type(olive::TreeView);
set_view_type(ProjectToolbar::TreeView);
// Set default icon size
SizeChangedSlot(olive::kProjectIconSizeDefault);
SizeChangedSlot(kProjectIconSizeDefault);
// Set rename timer timeout
rename_timer_.setInterval(500);
connect(&rename_timer_, SIGNAL(timeout()), this, SLOT(RenameTimerSlot()));
connect(&rename_timer_, &QTimer::timeout, this, &ProjectExplorer::RenameTimerSlot);
connect(tree_view_, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(ShowContextMenu()));
connect(list_view_, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(ShowContextMenu()));
connect(icon_view_, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(ShowContextMenu()));
connect(tree_view_, &ProjectExplorerTreeView::customContextMenuRequested, this, &ProjectExplorer::ShowContextMenu);
connect(list_view_, &ProjectExplorerListView::customContextMenuRequested, this, &ProjectExplorer::ShowContextMenu);
connect(icon_view_, &ProjectExplorerIconView::customContextMenuRequested, this, &ProjectExplorer::ShowContextMenu);
}
const olive::ProjectViewType &ProjectExplorer::view_type()
const ProjectToolbar::ViewType &ProjectExplorer::view_type()
{
return view_type_;
}
void ProjectExplorer::set_view_type(olive::ProjectViewType type)
void ProjectExplorer::set_view_type(ProjectToolbar::ViewType type)
{
view_type_ = type;
// Set widget based on view type
switch (view_type_) {
case olive::TreeView:
case ProjectToolbar::TreeView:
stacked_widget_->setCurrentWidget(tree_view_);
nav_bar_->setVisible(false);
break;
case olive::ListView:
case ProjectToolbar::ListView:
stacked_widget_->setCurrentWidget(list_view_);
nav_bar_->setVisible(true);
break;
case olive::IconView:
case ProjectToolbar::IconView:
stacked_widget_->setCurrentWidget(icon_view_);
nav_bar_->setVisible(true);
break;
@@ -172,7 +171,7 @@ void ProjectExplorer::DoubleClickViewSlot(const QModelIndex &index)
// If the item is a folder, browse to it
if (i->CanHaveChildren()
&& (view_type() == olive::ListView || view_type() == olive::IconView)) {
&& (view_type() == ProjectToolbar::ListView || view_type() == ProjectToolbar::IconView)) {
BrowseToFolder(index);
@@ -232,12 +231,12 @@ void ProjectExplorer::ShowContextMenu()
if (selected_items.isEmpty()) {
// FIXME: These are both duplicates of items from MainMenu, is there any way to re-use the code?
QAction* import_action = menu.addAction(tr("&Import..."));
connect(import_action, SIGNAL(triggered(bool)), &olive::core, SLOT(DialogImportShow()));
connect(import_action, SIGNAL(triggered(bool)), Core::instance(), SLOT(DialogImportShow()));
menu.addSeparator();
QAction* project_properties = menu.addAction(tr("&Project Properties..."));
connect(project_properties, SIGNAL(triggered(bool)), &olive::core, SLOT(DialogProjectPropertiesShow()));
connect(project_properties, SIGNAL(triggered(bool)), Core::instance(), SLOT(DialogProjectPropertiesShow()));
} else {
QAction* properties_action = menu.addAction(tr("P&roperties"));
+4 -4
View File
@@ -27,11 +27,11 @@
#include "project/project.h"
#include "project/projectviewmodel.h"
#include "project/projectviewtype.h"
#include "widget/projectexplorer/projectexplorericonview.h"
#include "widget/projectexplorer/projectexplorerlistview.h"
#include "widget/projectexplorer/projectexplorertreeview.h"
#include "widget/projectexplorer/projectexplorernavigation.h"
#include "widget/projecttoolbar/projecttoolbar.h"
/**
* @brief A widget for browsing through a Project structure.
@@ -47,7 +47,7 @@ class ProjectExplorer : public QWidget
public:
ProjectExplorer(QWidget* parent);
const olive::ProjectViewType& view_type();
const ProjectToolbar::ViewType& view_type();
Project* project();
void set_project(Project* p);
@@ -74,7 +74,7 @@ public:
ProjectViewModel* model();
public slots:
void set_view_type(olive::ProjectViewType type);
void set_view_type(ProjectToolbar::ViewType type);
void Edit(Item* item);
@@ -124,7 +124,7 @@ private:
ProjectExplorerListView* list_view_;
ProjectExplorerTreeView* tree_view_;
olive::ProjectViewType view_type_;
ProjectToolbar::ViewType view_type_;
ProjectViewModel model_;
@@ -1,17 +0,0 @@
#ifndef PROJECTEXPLORERDEFINES_H
#define PROJECTEXPLORERDEFINES_H
namespace olive {
/// The minimum size an icon in ProjectExplorer can be
const int kProjectIconSizeMinimum = 16;
/// The maximum size an icon in ProjectExplorer can be
const int kProjectIconSizeMaximum = 256;
/// The default size an icon in ProjectExplorer can be
const int kProjectIconSizeDefault = 64;
}
#endif // PROJECTEXPLORERDEFINES_H
@@ -23,8 +23,8 @@
#include <QEvent>
#include <QHBoxLayout>
#include "common/define.h"
#include "ui/icons/icons.h"
#include "widget/projectexplorer/projectexplorerdefines.h"
ProjectExplorerNavigation::ProjectExplorerNavigation(QWidget *parent) :
QWidget(parent)
@@ -89,7 +89,7 @@ void ProjectExplorerNavigation::Retranslate()
void ProjectExplorerNavigation::UpdateIcons()
{
dir_up_btn_->setIcon(icon::DirUp);
size_slider_->setMinimum(olive::kProjectIconSizeMinimum);
size_slider_->setMaximum(olive::kProjectIconSizeMaximum);
size_slider_->setValue(olive::kProjectIconSizeDefault);
size_slider_->setMinimum(kProjectIconSizeMinimum);
size_slider_->setMaximum(kProjectIconSizeMaximum);
size_slider_->setValue(kProjectIconSizeDefault);
}
@@ -35,15 +35,15 @@
* * Double clicking a Folder in those views will enter that folder
* * This navigation bar offers a "directory up" button for leaving a folder
*
* This navbar also provides an icon size slider for those views (between olive::kProjectIconSizeMinimum and
* olive::kProjectIconSizeMaximum) as well as text that's intended to be set to the current Folder's name (or
* This navbar also provides an icon size slider for those views (between kProjectIconSizeMinimum and
* kProjectIconSizeMaximum) as well as text that's intended to be set to the current Folder's name (or
* empty for the root folder).
*
* This widget does not actually communicate to Project or ProjectExplorer classes. It is simply UI widgets that are
* intended to be connected in ways that do. This is the primarily responsibility of ProjectExplorer.
*
* By default, the directory up button is disabled (assuming root folder), the text is empty, and the icon size slider
* is set to olive::kProjectIconSizeDefault.
* is set to kProjectIconSizeDefault.
*/
class ProjectExplorerNavigation : public QWidget
{
+7 -7
View File
@@ -84,16 +84,16 @@ ProjectToolbar::ProjectToolbar(QWidget *parent) :
UpdateIcons();
}
void ProjectToolbar::SetView(olive::ProjectViewType type)
void ProjectToolbar::SetView(ViewType type)
{
switch (type) {
case olive::TreeView:
case TreeView:
tree_button_->setChecked(true);
break;
case olive::IconView:
case IconView:
icon_button_->setChecked(true);
break;
case olive::ListView:
case ListView:
list_button_->setChecked(true);
break;
}
@@ -140,11 +140,11 @@ void ProjectToolbar::ViewButtonClicked()
{
// Determine which view button triggered this slot and emit a signal accordingly
if (sender() == tree_button_) {
emit ViewChanged(olive::TreeView);
emit ViewChanged(ProjectToolbar::TreeView);
} else if (sender() == icon_button_) {
emit ViewChanged(olive::IconView);
emit ViewChanged(ProjectToolbar::IconView);
} else if (sender() == list_button_) {
emit ViewChanged(olive::ListView);
emit ViewChanged(ProjectToolbar::ListView);
} else {
// Assert that it was one of the above buttons
abort();
+8 -4
View File
@@ -25,8 +25,6 @@
#include <QLineEdit>
#include <QPushButton>
#include "project/projectviewtype.h"
/**
* @brief The ProjectToolbar class
*
@@ -41,8 +39,14 @@ class ProjectToolbar : public QWidget
public:
ProjectToolbar(QWidget* parent);
enum ViewType {
TreeView,
ListView,
IconView
};
public slots:
void SetView(olive::ProjectViewType type);
void SetView(ViewType type);
protected:
void changeEvent(QEvent *) override;
@@ -57,7 +61,7 @@ signals:
void SearchChanged(const QString&);
void ViewChanged(olive::ProjectViewType type);
void ViewChanged(ViewType type);
private:
void Retranslate();
+13 -13
View File
@@ -256,22 +256,22 @@ void TimelineWidget::DeselectAll()
void TimelineWidget::RippleToIn()
{
RippleEditTo(olive::timeline::kTrimIn, false);
RippleEditTo(Timeline::kTrimIn, false);
}
void TimelineWidget::RippleToOut()
{
RippleEditTo(olive::timeline::kTrimOut, false);
RippleEditTo(Timeline::kTrimOut, false);
}
void TimelineWidget::EditToIn()
{
RippleEditTo(olive::timeline::kTrimIn, true);
RippleEditTo(Timeline::kTrimIn, true);
}
void TimelineWidget::EditToOut()
{
RippleEditTo(olive::timeline::kTrimOut, true);
RippleEditTo(Timeline::kTrimOut, true);
}
void TimelineWidget::GoToPrevCut()
@@ -382,7 +382,7 @@ void TimelineWidget::SplitAtPlayhead()
}
if (!blocks_to_split.isEmpty()) {
olive::undo_stack.push(new BlockSplitPreservingLinksCommand(blocks_to_split, {playhead_time}));
Core::instance()->undo_stack()->push(new BlockSplitPreservingLinksCommand(blocks_to_split, {playhead_time}));
}
}
@@ -470,7 +470,7 @@ void TimelineWidget::DeleteSelected()
DeleteSelectedInternal(blocks_to_delete, true, command);
olive::undo_stack.pushIfHasChildren(command);
Core::instance()->undo_stack()->pushIfHasChildren(command);
}
QList<TimelineViewBlockItem *> TimelineWidget::GetSelectedBlocks()
@@ -492,12 +492,12 @@ QList<TimelineViewBlockItem *> TimelineWidget::GetSelectedBlocks()
return list;
}
void TimelineWidget::RippleEditTo(olive::timeline::MovementMode mode, bool insert_gaps)
void TimelineWidget::RippleEditTo(Timeline::MovementMode mode, bool insert_gaps)
{
rational playhead_time = Timecode::timestamp_to_time(playhead_, timebase());
rational closest_point_to_playhead;
if (mode == olive::timeline::kTrimIn) {
if (mode == Timeline::kTrimIn) {
closest_point_to_playhead = 0;
} else {
closest_point_to_playhead = RATIONAL_MAX;
@@ -507,7 +507,7 @@ void TimelineWidget::RippleEditTo(olive::timeline::MovementMode mode, bool inser
Block* b = track->NearestBlockBefore(playhead_time);
if (b != nullptr) {
if (mode == olive::timeline::kTrimIn) {
if (mode == Timeline::kTrimIn) {
closest_point_to_playhead = qMax(b->in(), closest_point_to_playhead);
} else {
closest_point_to_playhead = qMin(b->out(), closest_point_to_playhead);
@@ -519,7 +519,7 @@ void TimelineWidget::RippleEditTo(olive::timeline::MovementMode mode, bool inser
if (closest_point_to_playhead == playhead_time) {
// Remove one frame only
if (mode == olive::timeline::kTrimIn) {
if (mode == Timeline::kTrimIn) {
playhead_time += timebase();
} else {
playhead_time -= timebase();
@@ -548,9 +548,9 @@ void TimelineWidget::RippleEditTo(olive::timeline::MovementMode mode, bool inser
}
}
olive::undo_stack.pushIfHasChildren(command);
Core::instance()->undo_stack()->pushIfHasChildren(command);
if (mode == olive::timeline::kTrimIn && !insert_gaps) {
if (mode == Timeline::kTrimIn && !insert_gaps) {
int64_t new_time = Timecode::time_to_timestamp(closest_point_to_playhead, timebase());
SetTimeAndSignal(new_time);
@@ -639,7 +639,7 @@ void TimelineWidget::UpdateTimelineLength(const rational &length)
TimelineWidget::Tool *TimelineWidget::GetActiveTool()
{
return tools_.at(olive::core.tool()).get();
return tools_.at(Core::instance()->tool()).get();
}
void TimelineWidget::ViewMousePressed(TimelineViewMouseEvent *event)
+11 -10
View File
@@ -5,6 +5,7 @@
#include <QRubberBand>
#include <QWidget>
#include "core.h"
#include "timelineandtrackview.h"
#include "widget/slider/timeslider.h"
#include "widget/timelinewidget/timelinescaledobject.h"
@@ -83,7 +84,7 @@ private:
TimelineWidget* parent();
static olive::timeline::MovementMode FlipTrimMode(const olive::timeline::MovementMode& trim_mode);
static Timeline::MovementMode FlipTrimMode(const Timeline::MovementMode& trim_mode);
protected:
/**
@@ -147,12 +148,12 @@ private:
virtual rational FrameValidateInternal(rational time_movement, const QVector<TimelineViewGhostItem *> &ghosts);
virtual void InitiateGhosts(TimelineViewBlockItem* clicked_item,
olive::timeline::MovementMode trim_mode,
Timeline::MovementMode trim_mode,
bool allow_gap_trimming);
TimelineViewGhostItem* AddGhostFromBlock(Block *block, const TrackReference& track, olive::timeline::MovementMode mode);
TimelineViewGhostItem* AddGhostFromBlock(Block *block, const TrackReference& track, Timeline::MovementMode mode);
TimelineViewGhostItem* AddGhostFromNull(const rational& in, const rational& out, const TrackReference& track, olive::timeline::MovementMode mode);
TimelineViewGhostItem* AddGhostFromNull(const rational& in, const rational& out, const TrackReference& track, Timeline::MovementMode mode);
/**
* @brief Validates Ghosts that are getting their in points trimmed
@@ -175,11 +176,11 @@ private:
private:
void InitiateDrag(const TimelineCoordinate &mouse_pos);
void AddGhostInternal(TimelineViewGhostItem* ghost, olive::timeline::MovementMode mode);
void AddGhostInternal(TimelineViewGhostItem* ghost, Timeline::MovementMode mode);
bool IsClipTrimmable(TimelineViewBlockItem* clip,
const QList<TimelineViewBlockItem*>& items,
const olive::timeline::MovementMode& mode);
const Timeline::MovementMode& mode);
TrackReference track_start_;
bool movement_allowed_;
@@ -225,7 +226,7 @@ private:
virtual rational FrameValidateInternal(rational time_movement, const QVector<TimelineViewGhostItem*>& ghosts) override;
virtual void InitiateGhosts(TimelineViewBlockItem* clicked_item,
olive::timeline::MovementMode trim_mode,
Timeline::MovementMode trim_mode,
bool allow_gap_trimming) override;
};
@@ -239,7 +240,7 @@ private:
virtual rational FrameValidateInternal(rational time_movement, const QVector<TimelineViewGhostItem*>& ghosts) override;
virtual void InitiateGhosts(TimelineViewBlockItem* clicked_item,
olive::timeline::MovementMode trim_mode,
Timeline::MovementMode trim_mode,
bool allow_gap_trimming) override;
};
@@ -252,7 +253,7 @@ private:
virtual void MouseReleaseInternal(TimelineViewMouseEvent *event) override;
virtual rational FrameValidateInternal(rational time_movement, const QVector<TimelineViewGhostItem*>& ghosts) override;
virtual void InitiateGhosts(TimelineViewBlockItem* clicked_item,
olive::timeline::MovementMode trim_mode,
Timeline::MovementMode trim_mode,
bool allow_gap_trimming) override;
};
@@ -353,7 +354,7 @@ private:
QMap<Block*, TimelineViewBlockItem*> block_items_;
void RippleEditTo(olive::timeline::MovementMode mode, bool insert_gaps);
void RippleEditTo(Timeline::MovementMode mode, bool insert_gaps);
void SetTimeAndSignal(const int64_t& t);
+1 -1
View File
@@ -61,7 +61,7 @@ void TimelineWidget::AddTool::MouseRelease(TimelineViewMouseEvent *event)
ghost_->GetAdjustedIn(),
command);
olive::undo_stack.push(command);
Core::instance()->undo_stack()->push(command);
}
parent()->ClearGhosts();
+3 -3
View File
@@ -139,7 +139,7 @@ void TimelineWidget::ImportTool::DragEnter(TimelineViewMouseEvent *event)
snap_points_.append(ghost->Out());
ghost->setData(TimelineViewGhostItem::kAttachedFootage, QVariant::fromValue(stream));
ghost->SetMode(olive::timeline::kMove);
ghost->SetMode(Timeline::kMove);
parent()->AddGhost(ghost);
}
@@ -163,7 +163,7 @@ void TimelineWidget::ImportTool::DragMove(TimelineViewMouseEvent *event)
int track_movement = event->GetCoordinates().GetTrack().index() - drag_start_.GetTrack().index();
// If snapping is enabled, check for snap points
if (olive::core.snapping()) {
if (Core::instance()->snapping()) {
SnapPoint(snap_points_, &time_movement);
}
@@ -289,7 +289,7 @@ void TimelineWidget::ImportTool::DragDrop(TimelineViewMouseEvent *event)
}
}
olive::undo_stack.pushIfHasChildren(command);
Core::instance()->undo_stack()->pushIfHasChildren(command);
parent()->ClearGhosts();
+32 -32
View File
@@ -193,11 +193,11 @@ void TimelineWidget::PointerTool::MouseReleaseInternal(TimelineViewMouseEvent *e
Block* b = Node::ValueToPtr<Block>(ghost->data(TimelineViewGhostItem::kAttachedBlock));
// Normal blocks work in conjunction with the gap made above
if (ghost->mode() == olive::timeline::kTrimIn || ghost->mode() == olive::timeline::kTrimOut) {
if (ghost->mode() == Timeline::kTrimIn || ghost->mode() == Timeline::kTrimOut) {
// If we were trimming, we'll need to change the length
// If we were trimming the in point, we'll need to adjust the media in too
if (ghost->mode() == olive::timeline::kTrimIn) {
if (ghost->mode() == Timeline::kTrimIn) {
new BlockResizeWithMediaInCommand(b, ghost->AdjustedLength(), command);
} else {
new BlockResizeCommand(b, ghost->AdjustedLength(), command);
@@ -213,7 +213,7 @@ void TimelineWidget::PointerTool::MouseReleaseInternal(TimelineViewMouseEvent *e
command);
}
olive::undo_stack.pushIfHasChildren(command);
Core::instance()->undo_stack()->pushIfHasChildren(command);
}
rational TimelineWidget::PointerTool::FrameValidateInternal(rational time_movement, const QVector<TimelineViewGhostItem *>& ghosts)
@@ -245,7 +245,7 @@ void TimelineWidget::PointerTool::InitiateDrag(const TimelineCoordinate &mouse_p
track_start_ = mouse_pos.GetTrack();
// Determine whether we're trimming or moving based on the position of the cursor
olive::timeline::MovementMode trim_mode = olive::timeline::kNone;
Timeline::MovementMode trim_mode = Timeline::kNone;
// FIXME: Hardcoded number
const int kTrimHandle = 10;
@@ -253,21 +253,21 @@ void TimelineWidget::PointerTool::InitiateDrag(const TimelineCoordinate &mouse_p
qreal mouse_x = parent()->TimeToScene(mouse_pos.GetFrame());
if (trimming_allowed_ && mouse_x < clicked_item->x() + kTrimHandle) {
trim_mode = olive::timeline::kTrimIn;
trim_mode = Timeline::kTrimIn;
} else if (trimming_allowed_ && mouse_x > clicked_item->x() + clicked_item->rect().right() - kTrimHandle) {
trim_mode = olive::timeline::kTrimOut;
trim_mode = Timeline::kTrimOut;
} else if (movement_allowed_) {
// Some derived classes don't allow movement
trim_mode = olive::timeline::kMove;
trim_mode = Timeline::kMove;
}
// Gaps can't be moved, only trimmed
if (clicked_item->block()->type() == Block::kGap && trim_mode == olive::timeline::kMove) {
trim_mode = olive::timeline::kNone;
if (clicked_item->block()->type() == Block::kGap && trim_mode == Timeline::kMove) {
trim_mode = Timeline::kNone;
}
// Make sure we can actually perform an action here
if (trim_mode != olive::timeline::kNone) {
if (trim_mode != Timeline::kNone) {
InitiateGhosts(clicked_item, trim_mode, false);
}
}
@@ -287,7 +287,7 @@ void TimelineWidget::PointerTool::ProcessDrag(const TimelineCoordinate &mouse_po
rational time_movement = mouse_pos.GetFrame() - drag_start_.GetFrame();
// Perform snapping if enabled (adjusts time_movement if it's close to any potential snap points)
if (olive::core.snapping()) {
if (Core::instance()->snapping()) {
SnapPoint(snap_points_, &time_movement);
}
@@ -298,15 +298,15 @@ void TimelineWidget::PointerTool::ProcessDrag(const TimelineCoordinate &mouse_po
// Perform movement
foreach (TimelineViewGhostItem* ghost, parent()->ghost_items_) {
switch (ghost->mode()) {
case olive::timeline::kNone:
case Timeline::kNone:
break;
case olive::timeline::kTrimIn:
case Timeline::kTrimIn:
ghost->SetInAdjustment(time_movement);
break;
case olive::timeline::kTrimOut:
case Timeline::kTrimOut:
ghost->SetOutAdjustment(time_movement);
break;
case olive::timeline::kMove:
case Timeline::kMove:
{
ghost->SetInAdjustment(time_movement);
ghost->SetOutAdjustment(time_movement);
@@ -341,7 +341,7 @@ void TimelineWidget::PointerTool::ProcessDrag(const TimelineCoordinate &mouse_po
}
void TimelineWidget::PointerTool::InitiateGhosts(TimelineViewBlockItem* clicked_item,
olive::timeline::MovementMode trim_mode,
Timeline::MovementMode trim_mode,
bool allow_gap_trimming)
{
// Convert selected items list to clips list
@@ -352,8 +352,8 @@ void TimelineWidget::PointerTool::InitiateGhosts(TimelineViewBlockItem* clicked_
bool multitrim_enabled = true;
// Determine if the clicked item is the earliest/latest in the track for in/out trimming respectively
if (trim_mode == olive::timeline::kTrimIn
|| trim_mode == olive::timeline::kTrimOut) {
if (trim_mode == Timeline::kTrimIn
|| trim_mode == Timeline::kTrimOut) {
multitrim_enabled = IsClipTrimmable(clicked_item, clips, trim_mode);
}
@@ -367,16 +367,16 @@ void TimelineWidget::PointerTool::InitiateGhosts(TimelineViewBlockItem* clicked_
bool include_this_clip = true;
if (clip_item != clicked_item
&& (trim_mode == olive::timeline::kTrimIn || trim_mode == olive::timeline::kTrimOut)) {
&& (trim_mode == Timeline::kTrimIn || trim_mode == Timeline::kTrimOut)) {
include_this_clip = multitrim_enabled ? IsClipTrimmable(clip_item, clips, trim_mode) : false;
}
if (include_this_clip) {
Block* block = clip_item->block();
olive::timeline::MovementMode block_mode = trim_mode;
Timeline::MovementMode block_mode = trim_mode;
if (block->type() == Block::kGap && !allow_gap_trimming) {
if (trim_mode == olive::timeline::kTrimIn) {
if (trim_mode == Timeline::kTrimIn) {
// Trim the previous clip's out point instead
block = block->previous();
} else {
@@ -393,7 +393,7 @@ void TimelineWidget::PointerTool::InitiateGhosts(TimelineViewBlockItem* clicked_
}
}
TimelineViewGhostItem* TimelineWidget::PointerTool::AddGhostFromBlock(Block* block, const TrackReference& track, olive::timeline::MovementMode mode)
TimelineViewGhostItem* TimelineWidget::PointerTool::AddGhostFromBlock(Block* block, const TrackReference& track, Timeline::MovementMode mode)
{
TimelineViewGhostItem* ghost = TimelineViewGhostItem::FromBlock(block,
track,
@@ -405,7 +405,7 @@ TimelineViewGhostItem* TimelineWidget::PointerTool::AddGhostFromBlock(Block* blo
return ghost;
}
TimelineViewGhostItem* TimelineWidget::PointerTool::AddGhostFromNull(const rational &in, const rational &out, const TrackReference& track, olive::timeline::MovementMode mode)
TimelineViewGhostItem* TimelineWidget::PointerTool::AddGhostFromNull(const rational &in, const rational &out, const TrackReference& track, Timeline::MovementMode mode)
{
TimelineViewGhostItem* ghost = new TimelineViewGhostItem();
@@ -419,20 +419,20 @@ TimelineViewGhostItem* TimelineWidget::PointerTool::AddGhostFromNull(const ratio
return ghost;
}
void TimelineWidget::PointerTool::AddGhostInternal(TimelineViewGhostItem* ghost, olive::timeline::MovementMode mode)
void TimelineWidget::PointerTool::AddGhostInternal(TimelineViewGhostItem* ghost, Timeline::MovementMode mode)
{
ghost->SetMode(mode);
// Prepare snap points (optimizes snapping for later)
switch (mode) {
case olive::timeline::kMove:
case Timeline::kMove:
snap_points_.append(ghost->In());
snap_points_.append(ghost->Out());
break;
case olive::timeline::kTrimIn:
case Timeline::kTrimIn:
snap_points_.append(ghost->In());
break;
case olive::timeline::kTrimOut:
case Timeline::kTrimOut:
snap_points_.append(ghost->Out());
break;
default:
@@ -444,13 +444,13 @@ void TimelineWidget::PointerTool::AddGhostInternal(TimelineViewGhostItem* ghost,
bool TimelineWidget::PointerTool::IsClipTrimmable(TimelineViewBlockItem* clip,
const QList<TimelineViewBlockItem*>& items,
const olive::timeline::MovementMode& mode)
const Timeline::MovementMode& mode)
{
foreach (TimelineViewBlockItem* compare, items) {
if (clip->Track() == compare->Track()
&& clip != compare
&& ((compare->block()->in() < clip->block()->in() && mode == olive::timeline::kTrimIn)
|| (compare->block()->out() > clip->block()->out() && mode == olive::timeline::kTrimOut))) {
&& ((compare->block()->in() < clip->block()->in() && mode == Timeline::kTrimIn)
|| (compare->block()->out() > clip->block()->out() && mode == Timeline::kTrimOut))) {
return false;
}
}
@@ -463,7 +463,7 @@ rational TimelineWidget::PointerTool::ValidateInTrimming(rational movement,
bool prevent_overwriting)
{
foreach (TimelineViewGhostItem* ghost, ghosts) {
if (ghost->mode() != olive::timeline::kTrimIn) {
if (ghost->mode() != Timeline::kTrimIn) {
continue;
}
@@ -508,7 +508,7 @@ rational TimelineWidget::PointerTool::ValidateOutTrimming(rational movement,
bool prevent_overwriting)
{
foreach (TimelineViewGhostItem* ghost, ghosts) {
if (ghost->mode() != olive::timeline::kTrimOut) {
if (ghost->mode() != Timeline::kTrimOut) {
continue;
}
+1 -1
View File
@@ -83,7 +83,7 @@ void TimelineWidget::RazorTool::MouseRelease(TimelineViewMouseEvent *event)
split_tracks_.clear();
olive::undo_stack.push(new BlockSplitPreservingLinksCommand(blocks_to_split, {split_time}));
Core::instance()->undo_stack()->push(new BlockSplitPreservingLinksCommand(blocks_to_split, {split_time}));
dragging_ = false;
}
+5 -5
View File
@@ -34,7 +34,7 @@ void TimelineWidget::RippleTool::MouseReleaseInternal(TimelineViewMouseEvent *ev
Q_UNUSED(event)
// For ripple operations, all ghosts will be moving the same way
olive::timeline::MovementMode movement_mode = parent()->ghost_items_.first()->mode();
Timeline::MovementMode movement_mode = parent()->ghost_items_.first()->mode();
QUndoCommand* command = new QUndoCommand();
@@ -62,7 +62,7 @@ void TimelineWidget::RippleTool::MouseReleaseInternal(TimelineViewMouseEvent *ev
} else {
// This was a Block that already existed
if (ghost->AdjustedLength() > 0) {
if (movement_mode == olive::timeline::kTrimIn) {
if (movement_mode == Timeline::kTrimIn) {
// We'll need to shift the media in point too
new BlockResizeWithMediaInCommand(b, ghost->AdjustedLength(), command);
} else {
@@ -77,7 +77,7 @@ void TimelineWidget::RippleTool::MouseReleaseInternal(TimelineViewMouseEvent *ev
}
}
olive::undo_stack.pushIfHasChildren(command);
Core::instance()->undo_stack()->pushIfHasChildren(command);
}
rational TimelineWidget::RippleTool::FrameValidateInternal(rational time_movement, const QVector<TimelineViewGhostItem *> &ghosts)
@@ -90,7 +90,7 @@ rational TimelineWidget::RippleTool::FrameValidateInternal(rational time_movemen
}
void TimelineWidget::RippleTool::InitiateGhosts(TimelineViewBlockItem *clicked_item,
olive::timeline::MovementMode trim_mode,
Timeline::MovementMode trim_mode,
bool allow_gap_trimming)
{
Q_UNUSED(allow_gap_trimming)
@@ -107,7 +107,7 @@ void TimelineWidget::RippleTool::InitiateGhosts(TimelineViewBlockItem *clicked_i
foreach (TimelineViewGhostItem* ghost, parent()->ghost_items_) {
rational ghost_ripple_point;
if (trim_mode == olive::timeline::kTrimIn) {
if (trim_mode == Timeline::kTrimIn) {
ghost_ripple_point = ghost->In();
} else {
ghost_ripple_point = ghost->Out();
+8 -8
View File
@@ -39,7 +39,7 @@ void TimelineWidget::RollingTool::MouseReleaseInternal(TimelineViewMouseEvent *e
foreach (TimelineViewGhostItem* ghost, parent()->ghost_items_) {
Block* b = Node::ValueToPtr<Block>(ghost->data(TimelineViewGhostItem::kAttachedBlock));
if (ghost->mode() == olive::timeline::kTrimIn) {
if (ghost->mode() == Timeline::kTrimIn) {
if (b->previous() == nullptr) {
// We'll need to insert a gap here, so we'll do a Place command instead
GapBlock* gap = new GapBlock();
@@ -62,12 +62,12 @@ void TimelineWidget::RollingTool::MouseReleaseInternal(TimelineViewMouseEvent *e
ghost->GetAdjustedIn(),
command);
}
} else if (ghost->mode() == olive::timeline::kTrimOut) {
} else if (ghost->mode() == Timeline::kTrimOut) {
new BlockResizeCommand(b, ghost->AdjustedLength(), command);
}
}
olive::undo_stack.pushIfHasChildren(command);
Core::instance()->undo_stack()->pushIfHasChildren(command);
}
rational TimelineWidget::RollingTool::FrameValidateInternal(rational time_movement, const QVector<TimelineViewGhostItem *> &ghosts)
@@ -80,7 +80,7 @@ rational TimelineWidget::RollingTool::FrameValidateInternal(rational time_moveme
}
void TimelineWidget::RollingTool::InitiateGhosts(TimelineViewBlockItem *clicked_item,
olive::timeline::MovementMode trim_mode,
Timeline::MovementMode trim_mode,
bool allow_gap_trimming)
{
Q_UNUSED(allow_gap_trimming)
@@ -91,11 +91,11 @@ void TimelineWidget::RollingTool::InitiateGhosts(TimelineViewBlockItem *clicked_
foreach (TimelineViewGhostItem* ghost, parent()->ghost_items_) {
Block* ghost_block = Node::ValueToPtr<Block>(ghost->data(TimelineViewGhostItem::kAttachedBlock));
if (ghost->mode() == olive::timeline::kTrimIn && ghost_block->previous() != nullptr) {
if (ghost->mode() == Timeline::kTrimIn && ghost_block->previous() != nullptr) {
// Add an extra Ghost for the previous block
AddGhostFromBlock(ghost_block->previous(), ghost->Track(), olive::timeline::kTrimOut);
} else if (ghost->mode() == olive::timeline::kTrimOut && ghost_block->next() != nullptr) {
AddGhostFromBlock(ghost_block->next(), ghost->Track(), olive::timeline::kTrimIn);
AddGhostFromBlock(ghost_block->previous(), ghost->Track(), Timeline::kTrimOut);
} else if (ghost->mode() == Timeline::kTrimOut && ghost_block->next() != nullptr) {
AddGhostFromBlock(ghost_block->next(), ghost->Track(), Timeline::kTrimIn);
}
}
}
+7 -7
View File
@@ -40,11 +40,11 @@ void TimelineWidget::SlideTool::MouseReleaseInternal(TimelineViewMouseEvent *eve
foreach (TimelineViewGhostItem* ghost, parent()->ghost_items_) {
Block* b = Node::ValueToPtr<Block>(ghost->data(TimelineViewGhostItem::kAttachedBlock));
if (ghost->mode() == olive::timeline::kTrimIn) {
if (ghost->mode() == Timeline::kTrimIn) {
new BlockResizeWithMediaInCommand(b, ghost->AdjustedLength(), command);
} else if (ghost->mode() == olive::timeline::kTrimOut) {
} else if (ghost->mode() == Timeline::kTrimOut) {
new BlockResizeCommand(b, ghost->AdjustedLength(), command);
} else if (ghost->mode() == olive::timeline::kMove && b->previous() == nullptr) {
} else if (ghost->mode() == Timeline::kMove && b->previous() == nullptr) {
GapBlock* gap = new GapBlock();
gap->set_length_and_media_out(ghost->InAdjustment());
new NodeAddCommand(static_cast<NodeGraph*>(b->parent()), gap, command);
@@ -52,7 +52,7 @@ void TimelineWidget::SlideTool::MouseReleaseInternal(TimelineViewMouseEvent *eve
}
}
olive::undo_stack.pushIfHasChildren(command);
Core::instance()->undo_stack()->pushIfHasChildren(command);
}
rational TimelineWidget::SlideTool::FrameValidateInternal(rational time_movement, const QVector<TimelineViewGhostItem *> &ghosts)
@@ -65,7 +65,7 @@ rational TimelineWidget::SlideTool::FrameValidateInternal(rational time_movement
}
void TimelineWidget::SlideTool::InitiateGhosts(TimelineViewBlockItem *clicked_item,
olive::timeline::MovementMode trim_mode,
Timeline::MovementMode trim_mode,
bool allow_gap_trimming)
{
Q_UNUSED(allow_gap_trimming)
@@ -80,11 +80,11 @@ void TimelineWidget::SlideTool::InitiateGhosts(TimelineViewBlockItem *clicked_it
if (ghost_block->previous() != nullptr) {
// Add an extra Ghost for the previous block
AddGhostFromBlock(ghost_block->previous(), ghost->Track(), olive::timeline::kTrimOut);
AddGhostFromBlock(ghost_block->previous(), ghost->Track(), Timeline::kTrimOut);
}
if (ghost_block->next() != nullptr) {
AddGhostFromBlock(ghost_block->next(), ghost->Track(), olive::timeline::kTrimIn);
AddGhostFromBlock(ghost_block->next(), ghost->Track(), Timeline::kTrimIn);
}
}
}
+1 -1
View File
@@ -78,6 +78,6 @@ void TimelineWidget::SlipTool::MouseReleaseInternal(TimelineViewMouseEvent *even
new BlockSetMediaOutCommand(b, ghost->GetAdjustedMediaIn() + b->media_length(), command);
}
olive::undo_stack.pushIfHasChildren(command);
Core::instance()->undo_stack()->pushIfHasChildren(command);
}
+7 -7
View File
@@ -39,14 +39,14 @@ TimelineWidget *TimelineWidget::Tool::parent()
return parent_;
}
olive::timeline::MovementMode TimelineWidget::Tool::FlipTrimMode(const olive::timeline::MovementMode &trim_mode)
Timeline::MovementMode TimelineWidget::Tool::FlipTrimMode(const Timeline::MovementMode &trim_mode)
{
if (trim_mode == olive::timeline::kTrimIn) {
return olive::timeline::kTrimOut;
if (trim_mode == Timeline::kTrimIn) {
return Timeline::kTrimOut;
}
if (trim_mode == olive::timeline::kTrimOut) {
return olive::timeline::kTrimIn;
if (trim_mode == Timeline::kTrimOut) {
return Timeline::kTrimIn;
}
return trim_mode;
@@ -97,7 +97,7 @@ void AttemptSnap(const QList<double>& proposed_pts,
rational TimelineWidget::Tool::ValidateFrameMovement(rational movement, const QVector<TimelineViewGhostItem *> ghosts)
{
foreach (TimelineViewGhostItem* ghost, ghosts) {
if (ghost->mode() != olive::timeline::kMove) {
if (ghost->mode() != Timeline::kMove) {
continue;
}
@@ -115,7 +115,7 @@ int TimelineWidget::Tool::ValidateTrackMovement(int movement, const QVector<Time
foreach (TimelineViewGhostItem* ghost, ghosts) {
// Prevents any ghosts from going to a non-existent negative track
if (ghost->Track().index() + movement < 0) {
if (ghost->mode() != olive::timeline::kMove) {
if (ghost->mode() != Timeline::kMove) {
continue;
}
@@ -26,13 +26,13 @@ void TimelineWidget::TransitionTool::MousePress(TimelineViewMouseEvent *event)
// Determine which side of the clip the transition belongs to
rational transition_start_point;
olive::timeline::MovementMode trim_mode;
Timeline::MovementMode trim_mode;
rational halfway_point = block_at_time->in() + block_at_time->length() / 2;
rational tenth_point = block_at_time->in() + block_at_time->length() / 10;
Block* other_block = nullptr;
if (cursor_frame < halfway_point) {
transition_start_point = block_at_time->in();
trim_mode = olive::timeline::kTrimIn;
trim_mode = Timeline::kTrimIn;
if (cursor_frame < tenth_point
&& block_at_time->previous()
@@ -41,7 +41,7 @@ void TimelineWidget::TransitionTool::MousePress(TimelineViewMouseEvent *event)
}
} else {
transition_start_point = block_at_time->out();
trim_mode = olive::timeline::kTrimOut;
trim_mode = Timeline::kTrimOut;
dual_transition_ = (cursor_frame > block_at_time->length() - tenth_point);
if (cursor_frame > block_at_time->length() - tenth_point
@@ -113,8 +113,8 @@ void TimelineWidget::TransitionTool::MouseRelease(TimelineViewMouseEvent *event)
Block* friend_block = Node::ValueToPtr<Block>(ghost_->data(TimelineViewGhostItem::kReferenceBlock));
// Use ghost mode to determine which block is which
Block* out_block = (ghost_->mode() == olive::timeline::kTrimIn) ? friend_block : active_block;
Block* in_block = (ghost_->mode() == olive::timeline::kTrimIn) ? active_block : friend_block;
Block* out_block = (ghost_->mode() == Timeline::kTrimIn) ? friend_block : active_block;
Block* in_block = (ghost_->mode() == Timeline::kTrimIn) ? active_block : friend_block;
// Connect block to transition
new NodeEdgeAddCommand(out_block->output(),
@@ -128,7 +128,7 @@ void TimelineWidget::TransitionTool::MouseRelease(TimelineViewMouseEvent *event)
Block* block_to_transition = Node::ValueToPtr<Block>(ghost_->data(TimelineViewGhostItem::kAttachedBlock));
NodeInput* transition_input_to_connect;
if (ghost_->mode() == olive::timeline::kTrimIn) {
if (ghost_->mode() == Timeline::kTrimIn) {
transition->set_in_and_out_offset(ghost_->AdjustedLength(), 0);
transition_input_to_connect = transition->in_block_input();
} else {
@@ -142,7 +142,7 @@ void TimelineWidget::TransitionTool::MouseRelease(TimelineViewMouseEvent *event)
command);
}
olive::undo_stack.push(command);
Core::instance()->undo_stack()->push(command);
}
parent()->ClearGhosts();
@@ -26,7 +26,7 @@ TimelineViewGhostItem::TimelineViewGhostItem(QGraphicsItem *parent) :
TimelineViewRect(parent),
track_adj_(0),
stream_(nullptr),
mode_(olive::timeline::kNone),
mode_(Timeline::kNone),
can_have_zero_length_(true)
{
SetInvisible(false);
@@ -174,12 +174,12 @@ TrackReference TimelineViewGhostItem::GetAdjustedTrack() const
return TrackReference(track_.type(), track_.index() + track_adj_);
}
const olive::timeline::MovementMode &TimelineViewGhostItem::mode() const
const Timeline::MovementMode &TimelineViewGhostItem::mode() const
{
return mode_;
}
void TimelineViewGhostItem::SetMode(const olive::timeline::MovementMode &mode)
void TimelineViewGhostItem::SetMode(const Timeline::MovementMode &mode)
{
mode_ = mode;
}
@@ -74,8 +74,8 @@ public:
rational GetAdjustedMediaIn() const;
TrackReference GetAdjustedTrack() const;
const olive::timeline::MovementMode& mode() const;
void SetMode(const olive::timeline::MovementMode& mode);
const Timeline::MovementMode& mode() const;
void SetMode(const Timeline::MovementMode& mode);
bool HasBeenAdjusted() const;
@@ -96,7 +96,7 @@ private:
StreamPtr stream_;
olive::timeline::MovementMode mode_;
Timeline::MovementMode mode_;
bool can_have_zero_length_;
};
+1 -1
View File
@@ -167,7 +167,7 @@ void ViewerWidget::ConnectViewerNode(ViewerOutput *node)
}
video_renderer_->SetViewerNode(viewer_node_);
video_renderer_->SetParameters(VideoRenderingParams(viewer_node_->video_params(), olive::PIX_FMT_RGBA16F, olive::kOffline, 2));
video_renderer_->SetParameters(VideoRenderingParams(viewer_node_->video_params(), PixelFormat::PIX_FMT_RGBA16F, RenderMode::kOffline, 2));
audio_renderer_->SetViewerNode(viewer_node_);
audio_renderer_->SetParameters(AudioRenderingParams(viewer_node_->audio_params(), SAMPLE_FMT_FLT));
+2 -2
View File
@@ -25,7 +25,7 @@
#include <QOpenGLFunctions>
#include <QOpenGLTexture>
#include "render/backend/opengl/functions.h"
#include "render/backend/opengl/openglrenderfunctions.h"
#include "render/backend/opengl/openglshader.h"
ViewerGLWidget::ViewerGLWidget(QWidget *parent) :
@@ -141,7 +141,7 @@ void ViewerGLWidget::paintGL()
f->glBindTexture(GL_TEXTURE_2D, texture_);
// Blit using the pipeline retrieved in initializeGL()
olive::gl::OCIOBlit(pipeline_, ocio_lut_, true, matrix_);
OpenGLRenderFunctions::OCIOBlit(pipeline_, ocio_lut_, true, matrix_);
// Release retrieved texture
f->glBindTexture(GL_TEXTURE_2D, 0);
+60 -32
View File
@@ -22,6 +22,7 @@
#include <QEvent>
#include "common/timecodefunctions.h"
#include "core.h"
#include "dialog/actionsearch/actionsearch.h"
#include "panel/panelmanager.h"
@@ -38,18 +39,18 @@ MainMenu::MainMenu(QMainWindow *parent) :
//
file_menu_ = new Menu(this, this, SLOT(FileMenuAboutToShow()));
file_new_menu_ = new Menu(file_menu_);
olive::menu_shared.AddItemsForNewMenu(file_new_menu_);
MenuShared::instance()->AddItemsForNewMenu(file_new_menu_);
file_open_item_ = file_menu_->AddItem("openproj", nullptr, nullptr, "Ctrl+O");
file_open_recent_menu_ = new Menu(file_menu_);
file_open_recent_clear_item_ = file_open_recent_menu_->AddItem("clearopenrecent", nullptr, nullptr);
file_save_item_ = file_menu_->AddItem("saveproj", nullptr, nullptr, "Ctrl+S");
file_save_as_item_ = file_menu_->AddItem("saveprojas", nullptr, nullptr, "Ctrl+Shift+S");
file_menu_->addSeparator();
file_import_item_ = file_menu_->AddItem("import", &olive::core, SLOT(DialogImportShow()), "Ctrl+I");
file_import_item_ = file_menu_->AddItem("import", Core::instance(), SLOT(DialogImportShow()), "Ctrl+I");
file_menu_->addSeparator();
file_export_item_ = file_menu_->AddItem("export", &olive::core, SLOT(DialogExportShow()), "Ctrl+M");
file_export_item_ = file_menu_->AddItem("export", Core::instance(), SLOT(DialogExportShow()), "Ctrl+M");
file_menu_->addSeparator();
file_project_properties_item_ = file_menu_->AddItem("projectproperties", &olive::core, SLOT(DialogProjectPropertiesShow()));
file_project_properties_item_ = file_menu_->AddItem("projectproperties", Core::instance(), SLOT(DialogProjectPropertiesShow()));
file_menu_->addSeparator();
file_exit_item_ = file_menu_->AddItem("exit", parent, SLOT(close()), "Ctrl+Q");
@@ -58,27 +59,27 @@ MainMenu::MainMenu(QMainWindow *parent) :
//
edit_menu_ = new Menu(this);
edit_undo_item_ = olive::undo_stack.createUndoAction(this);
edit_undo_item_ = Core::instance()->undo_stack()->createUndoAction(this);
Menu::ConformItem(edit_undo_item_, "undo", nullptr, nullptr, "Ctrl+Z");
edit_menu_->addAction(edit_undo_item_);
edit_redo_item_ = olive::undo_stack.createRedoAction(this);
edit_redo_item_ = Core::instance()->undo_stack()->createRedoAction(this);
Menu::ConformItem(edit_redo_item_, "redo", nullptr, nullptr, "Ctrl+Shift+Z");
edit_menu_->addAction(edit_redo_item_);
edit_menu_->addSeparator();
olive::menu_shared.AddItemsForEditMenu(edit_menu_);
MenuShared::instance()->AddItemsForEditMenu(edit_menu_);
edit_menu_->addSeparator();
edit_select_all_item_ = edit_menu_->AddItem("selectall", this, SLOT(SelectAllTriggered()), "Ctrl+A");
edit_deselect_all_item_ = edit_menu_->AddItem("deselectall", this, SLOT(DeselectAllTriggered()), "Ctrl+Shift+A");
edit_menu_->addSeparator();
olive::menu_shared.AddItemsForClipEditMenu(edit_menu_);
MenuShared::instance()->AddItemsForClipEditMenu(edit_menu_);
edit_menu_->addSeparator();
edit_ripple_to_in_item_ = edit_menu_->AddItem("rippletoin", this, SLOT(RippleToInTriggered()), "Q");
edit_ripple_to_out_item_ = edit_menu_->AddItem("rippletoout", this, SLOT(RippleToOutTriggered()), "W");
edit_edit_to_in_item_ = edit_menu_->AddItem("edittoin", this, SLOT(EditToInTriggered()), "Ctrl+Alt+Q");
edit_edit_to_out_item_ = edit_menu_->AddItem("edittoout", this, SLOT(EditToOutTriggered()), "Ctrl+Alt+W");
edit_menu_->addSeparator();
olive::menu_shared.AddItemsForInOutMenu(edit_menu_);
MenuShared::instance()->AddItemsForInOutMenu(edit_menu_);
edit_delete_inout_item_ = edit_menu_->AddItem("deleteinout", nullptr, nullptr, ";");
edit_ripple_delete_inout_item_ = edit_menu_->AddItem("rippledeleteinout", nullptr, nullptr, "'");
edit_menu_->addSeparator();
@@ -99,27 +100,32 @@ MainMenu::MainMenu(QMainWindow *parent) :
view_rectified_waveforms_item_->setCheckable(true);
view_menu_->addSeparator();
QActionGroup* frame_view_mode_group = new QActionGroup(this);
frame_view_mode_group_ = new QActionGroup(this);
view_timecode_view_frames_item_ = view_menu_->AddItem("modeframes", nullptr, nullptr);
//view_timecode_view_frames_item_->setData(olive::kTimecodeFrames);
view_timecode_view_frames_item_->setCheckable(true);
frame_view_mode_group->addAction(view_timecode_view_frames_item_);
view_timecode_view_dropframe_item_ = view_menu_->AddItem("modedropframe", nullptr, nullptr);
//view_timecode_view_dropframe_item_->setData(olive::kTimecodeDrop);
view_timecode_view_dropframe_item_ = view_menu_->AddItem("modedropframe", this, SLOT(TimecodeDisplayTriggered()));
view_timecode_view_dropframe_item_->setData(Timecode::kTimecodeDropFrame);
view_timecode_view_dropframe_item_->setCheckable(true);
frame_view_mode_group->addAction(view_timecode_view_dropframe_item_);
frame_view_mode_group_->addAction(view_timecode_view_dropframe_item_);
view_timecode_view_nondropframe_item_ = view_menu_->AddItem("modenondropframe", nullptr, nullptr);
//view_timecode_view_nondropframe_item_->setData(olive::kTimecodeNonDrop);
view_timecode_view_nondropframe_item_ = view_menu_->AddItem("modenondropframe", this, SLOT(TimecodeDisplayTriggered()));
view_timecode_view_nondropframe_item_->setData(Timecode::kTimecodeNonDropFrame);
view_timecode_view_nondropframe_item_->setCheckable(true);
frame_view_mode_group->addAction(view_timecode_view_nondropframe_item_);
frame_view_mode_group_->addAction(view_timecode_view_nondropframe_item_);
view_timecode_view_milliseconds_item_ = view_menu_->AddItem("milliseconds", nullptr, nullptr);
//view_timecode_view_milliseconds_item_->setData(olive::kTimecodeMilliseconds);
view_timecode_view_seconds_item_ = view_menu_->AddItem("modeseconds", this, SLOT(TimecodeDisplayTriggered()));
view_timecode_view_seconds_item_->setData(Timecode::kTimecodeSeconds);
view_timecode_view_seconds_item_->setCheckable(true);
frame_view_mode_group_->addAction(view_timecode_view_seconds_item_);
view_timecode_view_frames_item_ = view_menu_->AddItem("modeframes", this, SLOT(TimecodeDisplayTriggered()));
view_timecode_view_frames_item_->setData(Timecode::kFrames);
view_timecode_view_frames_item_->setCheckable(true);
frame_view_mode_group_->addAction(view_timecode_view_frames_item_);
view_timecode_view_milliseconds_item_ = view_menu_->AddItem("milliseconds", this, SLOT(TimecodeDisplayTriggered()));
view_timecode_view_milliseconds_item_->setData(Timecode::kMilliseconds);
view_timecode_view_milliseconds_item_->setCheckable(true);
frame_view_mode_group->addAction(view_timecode_view_milliseconds_item_);
frame_view_mode_group_->addAction(view_timecode_view_milliseconds_item_);
view_menu_->addSeparator();
@@ -265,7 +271,7 @@ MainMenu::MainMenu(QMainWindow *parent) :
tools_snapping_item_ = tools_menu_->AddItem("snapping", nullptr, nullptr, "S");
tools_snapping_item_->setCheckable(true);
connect(tools_snapping_item_, SIGNAL(triggered(bool)), &olive::core, SLOT(SetSnapping(bool)));
connect(tools_snapping_item_, SIGNAL(triggered(bool)), Core::instance(), SLOT(SetSnapping(bool)));
tools_menu_->addSeparator();
@@ -292,7 +298,7 @@ MainMenu::MainMenu(QMainWindow *parent) :
tools_menu_->addSeparator();
tools_preferences_item_ = tools_menu_->AddItem("prefs", &olive::core, SLOT(DialogPreferencesShow()), "Ctrl+,");
tools_preferences_item_ = tools_menu_->AddItem("prefs", Core::instance(), SLOT(DialogPreferencesShow()), "Ctrl+,");
//
// HELP MENU
@@ -302,7 +308,7 @@ MainMenu::MainMenu(QMainWindow *parent) :
help_menu_->addSeparator();
help_debug_log_item_ = help_menu_->AddItem("debuglog", nullptr, nullptr);
help_menu_->addSeparator();
help_about_item_ = help_menu_->AddItem("about", &olive::core, SLOT(DialogAboutShow()));
help_about_item_ = help_menu_->AddItem("about", Core::instance(), SLOT(DialogAboutShow()));
Retranslate();
}
@@ -324,18 +330,39 @@ void MainMenu::ToolItemTriggered()
Tool::Item tool = static_cast<Tool::Item>(action->data().toInt());
// Set the Tool in Core
olive::core.SetTool(tool);
Core::instance()->SetTool(tool);
}
void MainMenu::TimecodeDisplayTriggered()
{
// Assume the sender is a QAction
QAction* action = static_cast<QAction*>(sender());
// Assume its data() is a member of Timecode::Display
Timecode::Display display = static_cast<Timecode::Display>(action->data().toInt());
// Set the current display mode
Timecode::SetCurrentDisplay(display);
}
void MainMenu::FileMenuAboutToShow()
{
file_project_properties_item_->setEnabled(olive::core.GetActiveProject() != nullptr);
file_project_properties_item_->setEnabled(Core::instance()->GetActiveProject() != nullptr);
}
void MainMenu::ViewMenuAboutToShow()
{
// Parent is QMainWindow
view_full_screen_item_->setChecked(parentWidget()->isFullScreen());
// Ensure checked timecode display mode is correct
QList<QAction*> timecode_display_actions = frame_view_mode_group_->actions();
foreach (QAction* a, timecode_display_actions) {
if (a->data() == Timecode::CurrentDisplay()) {
a->setChecked(true);
break;
}
}
}
void MainMenu::ToolsMenuAboutToShow()
@@ -343,14 +370,14 @@ void MainMenu::ToolsMenuAboutToShow()
// Ensure checked Tool is correct
QList<QAction*> tool_actions = tools_group_->actions();
foreach (QAction* a, tool_actions) {
if (a->data() == olive::core.tool()) {
if (a->data() == Core::instance()->tool()) {
a->setChecked(true);
break;
}
}
// Ensure snapping value is correct
tools_snapping_item_->setChecked(olive::core.snapping());
tools_snapping_item_->setChecked(Core::instance()->snapping());
}
void MainMenu::WindowMenuAboutToShow()
@@ -478,7 +505,7 @@ void MainMenu::GoToNextCutTriggered()
void MainMenu::Retranslate()
{
// MenuShared is not a QWidget and therefore does not receive a LanguageEvent, we use MainMenu's to update it
olive::menu_shared.Retranslate();
MenuShared::instance()->Retranslate();
// File menu
file_menu_->setTitle(tr("&File"));
@@ -519,6 +546,7 @@ void MainMenu::Retranslate()
view_timecode_view_dropframe_item_->setText(tr("Drop Frame"));
view_timecode_view_nondropframe_item_->setText(tr("Non-Drop Frame"));
view_timecode_view_milliseconds_item_->setText(tr("Milliseconds"));
view_timecode_view_seconds_item_->setText(tr("Seconds"));
// View->Title/Action Safe Area Menu
view_title_safe_area_menu_->setTitle(tr("Title/Action Safe Area"));
+12 -2
View File
@@ -52,11 +52,19 @@ private slots:
/**
* @brief A slot for the Tool selection items
*
* Assumes a QAction* sender() and its data() is a member of enum olive::tool:Tool. Uses the data() to signal a
* 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();
/**
* @brief A slot for the timecode display menu items
*
* 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();
/**
* @brief Slot triggered just before the File menu shows
*/
@@ -164,9 +172,11 @@ private:
QAction* view_decrease_track_height_item_;
QAction* view_show_all_item_;
QAction* view_rectified_waveforms_item_;
QAction* view_timecode_view_frames_item_;
QActionGroup* frame_view_mode_group_;
QAction* view_timecode_view_dropframe_item_;
QAction* view_timecode_view_nondropframe_item_;
QAction* view_timecode_view_seconds_item_;
QAction* view_timecode_view_frames_item_;
QAction* view_timecode_view_milliseconds_item_;
Menu* view_title_safe_area_menu_;
QAction* title_safe_off_item_;