Skip to content

Commit

Permalink
Refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
darbyjohnston committed Mar 4, 2025
1 parent a84e5d1 commit 5c730d8
Show file tree
Hide file tree
Showing 37 changed files with 415 additions and 662 deletions.
148 changes: 0 additions & 148 deletions lib/tlPlayApp/Actions/RenderActions.cpp

This file was deleted.

42 changes: 0 additions & 42 deletions lib/tlPlayApp/Actions/RenderActions.h

This file was deleted.

100 changes: 100 additions & 0 deletions lib/tlPlayApp/Actions/ViewActions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,15 @@
#include <tlPlayApp/App.h>
#include <tlPlayApp/MainWindow.h>

#include <sstream>

namespace tl
{
namespace play
{
struct ViewActions::Private
{
std::vector<dtk::ImageType> colorBuffers;
std::map<std::string, std::shared_ptr<dtk::Action> > actions;
};

Expand Down Expand Up @@ -213,6 +216,98 @@ namespace tl
}
});


p.actions["FromFile"] = std::make_shared<dtk::Action>(
"From File",
[appWeak](bool value)
{
if (auto app = appWeak.lock())
{
auto imageOptions = app->getViewportModel()->getImageOptions();
imageOptions.videoLevels = dtk::InputVideoLevels::FromFile;
app->getViewportModel()->setImageOptions(imageOptions);
}
});

p.actions["FullRange"] = std::make_shared<dtk::Action>(
"Full Range",
[appWeak](bool value)
{
if (auto app = appWeak.lock())
{
auto imageOptions = app->getViewportModel()->getImageOptions();
imageOptions.videoLevels = dtk::InputVideoLevels::FullRange;
app->getViewportModel()->setImageOptions(imageOptions);
}
});

p.actions["LegalRange"] = std::make_shared<dtk::Action>(
"Legal Range",
[appWeak](bool value)
{
if (auto app = appWeak.lock())
{
auto imageOptions = app->getViewportModel()->getImageOptions();
imageOptions.videoLevels = dtk::InputVideoLevels::LegalRange;
app->getViewportModel()->setImageOptions(imageOptions);
}
});

p.actions["AlphaBlendNone"] = std::make_shared<dtk::Action>(
"None",
[appWeak](bool value)
{
if (auto app = appWeak.lock())
{
auto imageOptions = app->getViewportModel()->getImageOptions();
imageOptions.alphaBlend = dtk::AlphaBlend::None;
app->getViewportModel()->setImageOptions(imageOptions);
}
});

p.actions["AlphaBlendStraight"] = std::make_shared<dtk::Action>(
"Straight",
[appWeak](bool value)
{
if (auto app = appWeak.lock())
{
auto imageOptions = app->getViewportModel()->getImageOptions();
imageOptions.alphaBlend = dtk::AlphaBlend::Straight;
app->getViewportModel()->setImageOptions(imageOptions);
}
});

p.actions["AlphaBlendPremultiplied"] = std::make_shared<dtk::Action>(
"Premultiplied",
[appWeak](bool value)
{
if (auto app = appWeak.lock())
{
auto imageOptions = app->getViewportModel()->getImageOptions();
imageOptions.alphaBlend = dtk::AlphaBlend::Premultiplied;
app->getViewportModel()->setImageOptions(imageOptions);
}
});

p.colorBuffers.push_back(dtk::ImageType::RGBA_U8);
p.colorBuffers.push_back(dtk::ImageType::RGBA_F16);
p.colorBuffers.push_back(dtk::ImageType::RGBA_F32);
for (size_t i = 0; i < p.colorBuffers.size(); ++i)
{
const dtk::ImageType imageType = p.colorBuffers[i];
std::stringstream ss;
ss << imageType;
p.actions[ss.str()] = std::make_shared<dtk::Action>(
ss.str(),
[appWeak, imageType](bool value)
{
if (auto app = appWeak.lock())
{
app->getViewportModel()->setColorBuffer(imageType);
}
});
}

p.actions["HUD"] = std::make_shared<dtk::Action>(
"HUD",
dtk::Key::H,
Expand Down Expand Up @@ -244,6 +339,11 @@ namespace tl
return out;
}

const std::vector<dtk::ImageType>& ViewActions::getColorBuffers() const
{
return _p->colorBuffers;
}

const std::map<std::string, std::shared_ptr<dtk::Action> >& ViewActions::getActions() const
{
return _p->actions;
Expand Down
2 changes: 2 additions & 0 deletions lib/tlPlayApp/Actions/ViewActions.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ namespace tl
const std::shared_ptr<App>&,
const std::shared_ptr<MainWindow>&);

const std::vector<dtk::ImageType>& getColorBuffers() const;

const std::map<std::string, std::shared_ptr<dtk::Action> >& getActions() const;

private:
Expand Down
11 changes: 1 addition & 10 deletions lib/tlPlayApp/App.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
#include <tlPlayApp/Models/ColorModel.h>
#include <tlPlayApp/Models/FilesModel.h>
#include <tlPlayApp/Models/RecentFilesModel.h>
#include <tlPlayApp/Models/RenderModel.h>
#include <tlPlayApp/Models/TimeUnitsModel.h>
#include <tlPlayApp/Models/ViewportModel.h>
#if defined(TLRENDER_BMD)
Expand Down Expand Up @@ -94,7 +93,6 @@ namespace tl
std::shared_ptr<dtk::ObservableValue<std::shared_ptr<timeline::Player> > > player;
std::shared_ptr<ColorModel> colorModel;
std::shared_ptr<ViewportModel> viewportModel;
std::shared_ptr<RenderModel> renderModel;
std::shared_ptr<AudioModel> audioModel;
std::shared_ptr<ToolsModel> toolsModel;

Expand Down Expand Up @@ -286,11 +284,6 @@ namespace tl
return _p->viewportModel;
}

const std::shared_ptr<RenderModel>& App::getRenderModel() const
{
return _p->renderModel;
}

const std::shared_ptr<AudioModel>& App::getAudioModel() const
{
return _p->audioModel;
Expand Down Expand Up @@ -433,8 +426,6 @@ namespace tl

p.viewportModel = ViewportModel::create(_context, p.settings);

p.renderModel = RenderModel::create(_context, p.settings);

p.audioModel = AudioModel::create(_context, p.settings);

p.toolsModel = ToolsModel::create();
Expand Down Expand Up @@ -598,7 +589,7 @@ namespace tl
_p->bmdOutputDevice->setLUTOptions(value);
});
p.imageOptionsObserver = dtk::ValueObserver<dtk::ImageOptions>::create(
p.renderModel->observeImageOptions(),
p.viewportModel->observeImageOptions(),
[this](const dtk::ImageOptions& value)
{
_p->bmdOutputDevice->setImageOptions({ value });
Expand Down
4 changes: 0 additions & 4 deletions lib/tlPlayApp/App.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ namespace tl
class FilesModel;
class MainWindow;
class RecentFilesModel;
class RenderModel;
class SettingsModel;
class TimeUnitsModel;
class ToolsModel;
Expand Down Expand Up @@ -100,9 +99,6 @@ namespace tl
//! Get the viewport model.
const std::shared_ptr<ViewportModel>& getViewportModel() const;

//! Get the render model.
const std::shared_ptr<RenderModel>& getRenderModel() const;

//! Get the audio model.
const std::shared_ptr<AudioModel>& getAudioModel() const;

Expand Down
Loading

0 comments on commit 5c730d8

Please sign in to comment.