双缓冲先加上

This commit is contained in:
2026-08-11 17:48:32 +08:00
parent 542637ede4
commit 0327d71536
31 changed files with 1605 additions and 2248 deletions
+53
View File
@@ -0,0 +1,53 @@
#pragma once
#include "Renderable.h"
#include "../plot/Plot_Core.h"
#include <renderive/base/property/Concepts.hpp>
#include <renderive/base/property/Validators.hpp>
#include <functional>
#include <memory>
#include <utility>
namespace renderive {
template <Property_Product Product_Type, Property_Set Properties_Type, Property_Validator<Properties_Type> Validator_Type = No_Property_Validator<Properties_Type>>
class Renderable_Builder {
public:
using Product = Product_Type;
using Properties = Properties_Type;
using Validator = Validator_Type;
using Self = Renderable_Builder;
Renderable_Builder() requires std::default_initializable<Properties> && std::default_initializable<Validator> : properties{}, validator{} {}
explicit Renderable_Builder(Properties properties) requires std::default_initializable<Validator> : properties(std::move(properties)), validator{} {}
Renderable_Builder(Properties properties, Validator validator) : properties(std::move(properties)), validator(std::move(validator)) {}
template <auto Member, Property_Member_Assignable<Properties, Member> Value>
Self& set(Value&& value) {
properties.*Member = std::forward<Value>(value);
return *this;
}
template <Property_Configurator<Properties> Configure>
Self& configure(Configure&& configure) {
std::invoke(std::forward<Configure>(configure), properties);
return *this;
}
const Properties& properties_value() const noexcept {
return properties;
}
template <class... Args>
requires std::derived_from<Product, Renderable> && std::constructible_from<Product, Plot_Core&, const Properties&, Args&&...>
std::shared_ptr<Product> build(const std::shared_ptr<Renderable>& parent, Args&&... args) const {
if(!parent || !(valid_argument(args) && ...))
return {};
validator(properties);
return parent->plot().make_renderable<Product>(parent, properties, std::forward<Args>(args)...);
}
private:
template <class T>
static bool valid_argument(const std::shared_ptr<T>& value) {
return static_cast<bool>(value);
}
template <class T>
static bool valid_argument(const T&) {
return true;
}
Properties properties;
[[no_unique_address]] Validator validator;
};
}