Skip to content

Commit

Permalink
Refactoring
Browse files Browse the repository at this point in the history
Signed-off-by: Darby Johnston <[email protected]>
  • Loading branch information
darbyjohnston committed Nov 30, 2024
1 parent 1c6a1c1 commit 7d8dc45
Show file tree
Hide file tree
Showing 32 changed files with 514 additions and 512 deletions.
10 changes: 5 additions & 5 deletions lib/toucanView/App.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

#include "App.h"

#include "DocumentsModel.h"
#include "FilesModel.h"
#include "MainWindow.h"
#include "TimeUnitsModel.h"
#include "WindowModel.h"
Expand Down Expand Up @@ -59,7 +59,7 @@ namespace toucan
auto fileBrowserSystem = context->getSystem<dtk::FileBrowserSystem>();
fileBrowserSystem->setNativeFileDialog(false);

_documentsModel = std::make_shared<DocumentsModel>(context, _settings, _host);
_filesModel = std::make_shared<FilesModel>(context, _settings, _host);

_windowModel = std::make_shared<WindowModel>();

Expand All @@ -74,7 +74,7 @@ namespace toucan
{
try
{
_documentsModel->open(_path);
_filesModel->open(_path);
}
catch (const std::exception& e)
{
Expand Down Expand Up @@ -107,9 +107,9 @@ namespace toucan
return _host;
}

const std::shared_ptr<DocumentsModel>& App::getDocumentsModel() const
const std::shared_ptr<FilesModel>& App::getFilesModel() const
{
return _documentsModel;
return _filesModel;
}

const std::shared_ptr<WindowModel>& App::getWindowModel() const
Expand Down
6 changes: 3 additions & 3 deletions lib/toucanView/App.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

namespace toucan
{
class DocumentsModel;
class FilesModel;
class ImageEffectHost;
class MainWindow;
class MessageLog;
Expand All @@ -30,7 +30,7 @@ namespace toucan

const std::shared_ptr<TimeUnitsModel>& getTimeUnitsModel() const;
const std::shared_ptr<ImageEffectHost>& getHost() const;
const std::shared_ptr<DocumentsModel>& getDocumentsModel() const;
const std::shared_ptr<FilesModel>& getFilesModel() const;
const std::shared_ptr<WindowModel>& getWindowModel() const;

private:
Expand All @@ -39,7 +39,7 @@ namespace toucan
std::string _path;
std::shared_ptr<TimeUnitsModel> _timeUnitsModel;
std::shared_ptr<ImageEffectHost> _host;
std::shared_ptr<DocumentsModel> _documentsModel;
std::shared_ptr<FilesModel> _filesModel;
std::shared_ptr<WindowModel> _windowModel;
std::shared_ptr<MainWindow> _window;
};
Expand Down
12 changes: 6 additions & 6 deletions lib/toucanView/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
set(HEADERS
App.h
ClipItem.h
DocumentTab.h
Document.h
DocumentsModel.h
ExportTool.h
FileTab.h
File.h
FilesModel.h
GapItem.h
GraphTool.h
IItem.h
Expand All @@ -31,10 +31,10 @@ set(HEADERS
set(SOURCE
App.cpp
ClipItem.cpp
DocumentTab.cpp
Document.cpp
DocumentsModel.cpp
ExportTool.cpp
FileTab.cpp
File.cpp
FilesModel.cpp
GapItem.cpp
GraphTool.cpp
IItem.cpp
Expand Down
146 changes: 0 additions & 146 deletions lib/toucanView/DocumentsModel.cpp

This file was deleted.

24 changes: 12 additions & 12 deletions lib/toucanView/ExportTool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include "ExportTool.h"

#include "App.h"
#include "DocumentsModel.h"
#include "FilesModel.h"
#include "PlaybackModel.h"

#include <toucan/Util.h>
Expand Down Expand Up @@ -67,7 +67,7 @@ namespace toucan
exportSequenceButton->setClickedCallback(
[this]
{
_timeRange = _document->getPlaybackModel()->getInOutRange();
_timeRange = _file->getPlaybackModel()->getInOutRange();
_export();
});

Expand All @@ -79,32 +79,32 @@ namespace toucan
[this]
{
_timeRange = OTIO_NS::TimeRange(
_document->getPlaybackModel()->getCurrentTime(),
OTIO_NS::RationalTime(1.0, _document->getPlaybackModel()->getTimeRange().duration().rate()));
_file->getPlaybackModel()->getCurrentTime(),
OTIO_NS::RationalTime(1.0, _file->getPlaybackModel()->getTimeRange().duration().rate()));
_export();
});

_timer = dtk::Timer::create(context);
_timer->setRepeating(true);

_documentObserver = dtk::ValueObserver<std::shared_ptr<Document> >::create(
app->getDocumentsModel()->observeCurrent(),
[this](const std::shared_ptr<Document>& document)
_fileObserver = dtk::ValueObserver<std::shared_ptr<File> >::create(
app->getFilesModel()->observeCurrent(),
[this](const std::shared_ptr<File>& file)
{
_document = document;
if (_document)
_file = file;
if (_file)
{
_graph = std::make_shared<ImageGraph>(
_document->getPath(),
_document->getTimelineWrapper());
_file->getPath(),
_file->getTimelineWrapper());
}
else
{
_timeRange = OTIO_NS::TimeRange();
_time = OTIO_NS::RationalTime();
_graph.reset();
}
setEnabled(_document.get());
setEnabled(_file.get());
});
}

Expand Down
6 changes: 3 additions & 3 deletions lib/toucanView/ExportTool.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

namespace toucan
{
class Document;
class File;

class ExportWidget : public dtk::IWidget
{
Expand All @@ -45,7 +45,7 @@ namespace toucan
void _export();

std::shared_ptr<ImageEffectHost> _host;
std::shared_ptr<Document> _document;
std::shared_ptr<File> _file;
OTIO_NS::TimeRange _timeRange;
OTIO_NS::RationalTime _time;
std::shared_ptr<ImageGraph> _graph;
Expand All @@ -59,7 +59,7 @@ namespace toucan
std::shared_ptr<dtk::ProgressDialog> _dialog;
std::shared_ptr<dtk::Timer> _timer;

std::shared_ptr<dtk::ValueObserver<std::shared_ptr<Document> > > _documentObserver;
std::shared_ptr<dtk::ValueObserver<std::shared_ptr<File> > > _fileObserver;
};

class ExportTool : public IToolWidget
Expand Down
Loading

0 comments on commit 7d8dc45

Please sign in to comment.