Squashed 'deps/nostalgia/' changes from 6a523191..84205879

84205879 [olympic] Cleanup ItemMaker, remove unnecessary copy
ebf3a696 [ox/std] Add String constructor that takes a StringLiteral
dfd27afd [ox/std] Add implicit String constructor for str literals
6bfe1842 [ox/std] Remove unnecessary copying from HashMap::expand
700d7016 [nostalgia] Update for Ox changes
92232383 [ox] Cleanup
3b8d13dc [nostalgia,olympic] Fixes for Ox update
a20d7fd9 [ox] Cleanup
2c0e0227 [ox/std] Add assert to AnyPtr::Wrap::copyTo to ensure sufficiently large buff
e3c74637 [turbine] Make applicationData return const&
41e08d67 [turbine] Make keyEventHandler nodiscard
50f3479d [ox/std] Make AnyPtr constexpr
1616ca70 [turbine] Replace WrapPtr with ox::AnyPtr
3fa247e3 [ox/std] Add AnyPtr
27f1df8f [nostalgia,olympic] Further reduce use of applicationData
a4f0c7cd [nostalgia/core/studio] Remove applicationData usages

git-subtree-dir: deps/nostalgia
git-subtree-split: 84205879d46610dfe08098d1265c0398f2215d3d
This commit is contained in:
2024-04-21 10:33:10 -05:00
parent 5627a63572
commit c0baf7efca
76 changed files with 544 additions and 453 deletions

View File

@@ -18,7 +18,10 @@ class ItemMaker {
ox::String const typeName;
ox::String const parentDir;
ox::String const fileExt;
constexpr explicit ItemMaker(ox::StringView pName, ox::StringView pParentDir, ox::CRStringView pFileExt) noexcept:
constexpr explicit ItemMaker(
ox::StringView pName,
ox::StringView pParentDir,
ox::StringView pFileExt) noexcept:
typeName(pName),
parentDir(pParentDir),
fileExt(pFileExt) {
@@ -36,7 +39,8 @@ class ItemMaker {
* @param pName
* @return path of file or error in Result
*/
virtual ox::Result<ox::String> write(turbine::Context &ctx, ox::CRStringView pName) const noexcept = 0;
virtual ox::Result<ox::String> write(
studio::StudioContext &ctx, ox::CRStringView pName) const noexcept = 0;
};
template<typename T>
@@ -60,7 +64,7 @@ class ItemMakerT: public ItemMaker {
T pItem,
ox::ClawFormat pFmt) noexcept:
ItemMaker(pDisplayName, pParentDir, fileExt),
m_item(pItem),
m_item(std::move(pItem)),
m_fmt(pFmt) {
}
constexpr ItemMakerT(
@@ -73,11 +77,10 @@ class ItemMakerT: public ItemMaker {
m_item(std::move(pItem)),
m_fmt(pFmt) {
}
ox::Result<ox::String> write(turbine::Context &ctx, ox::CRStringView pName) const noexcept override {
ox::Result<ox::String> write(studio::StudioContext &sctx, ox::CRStringView pName) const noexcept override {
auto const path = itemPath(pName);
auto const sctx = turbine::applicationData<studio::StudioContext>(ctx);
keel::createUuidMapping(keelCtx(ctx), path, ox::UUID::generate().unwrap());
oxReturnError(sctx->project->writeObj(path, m_item, m_fmt));
keel::createUuidMapping(keelCtx(sctx.tctx), path, ox::UUID::generate().unwrap());
oxReturnError(sctx.project->writeObj(path, m_item, m_fmt));
return path;
}
};

View File

@@ -32,7 +32,7 @@ class Popup {
[[nodiscard]]
virtual bool isOpen() const noexcept = 0;
virtual void draw(turbine::Context &ctx) noexcept = 0;
virtual void draw(studio::StudioContext &ctx) noexcept = 0;
protected:
constexpr void setSize(ox::Size sz) noexcept {

View File

@@ -8,12 +8,14 @@
#include <turbine/context.hpp>
#include "context.hpp"
namespace studio {
class Widget: public ox::SignalHandler {
public:
~Widget() noexcept override = default;
virtual void draw(turbine::Context&) noexcept = 0;
virtual void draw(studio::StudioContext&) noexcept = 0;
};
}

View File

@@ -13,9 +13,9 @@ namespace studio {
FDFilterItem::FDFilterItem(ox::CRStringView pName, ox::CRStringView pSpec) noexcept {
name.resize(pName.len() + 1);
ox_strncpy(name.data(), pName.data(), pName.len());
ox::strncpy(name.data(), pName.data(), pName.len());
spec.resize(pSpec.len() + 1);
ox_strncpy(spec.data(), pSpec.data(), pSpec.len());
ox::strncpy(spec.data(), pSpec.data(), pSpec.len());
}
static ox::Result<ox::String> toResult(nfdresult_t r, NFD::UniquePathN const&path) noexcept {