builder 和 运行时修改隔离开
This commit is contained in:
@@ -5,7 +5,7 @@
|
||||
|
||||
namespace renderive {
|
||||
|
||||
Abs_Axis::Abs_Axis(::Scene_Base& scene) : Renderable(scene, true) {}
|
||||
Abs_Axis::Abs_Axis() : Renderable(true) {}
|
||||
|
||||
Abs_Axis::~Abs_Axis() = default;
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ namespace renderive {
|
||||
|
||||
class LIB_DECL Abs_Axis : public Renderable {
|
||||
public:
|
||||
explicit Abs_Axis(::Scene_Base& scene);
|
||||
Abs_Axis();
|
||||
~Abs_Axis() override;
|
||||
|
||||
[[nodiscard]] virtual Axis_Transform transform() const = 0;
|
||||
|
||||
@@ -1,24 +1,17 @@
|
||||
#pragma once
|
||||
|
||||
#include "../renderable/Renderable.h"
|
||||
#include "Axis_Types.h"
|
||||
#include <renderive/scene/base/Scene_Base.hpp>
|
||||
|
||||
#include <memory>
|
||||
#include <utility>
|
||||
|
||||
namespace renderive::detail {
|
||||
|
||||
template <class Product, class Properties, class...>
|
||||
class Axis_Renderable_Builder {
|
||||
public:
|
||||
using Self = Axis_Renderable_Builder;
|
||||
|
||||
Axis_Renderable_Builder(std::shared_ptr<Renderable> parent, Orientation orientation)
|
||||
: parent_(std::move(parent)) {
|
||||
Axis_Renderable_Builder(renderive_Owner<Renderable> parent, Orientation orientation, ::Scene_Base::Attach_Builder* attach_builder = nullptr)
|
||||
: parent_(std::move(parent)), attach_builder_(attach_builder) {
|
||||
properties_.orientation = orientation;
|
||||
}
|
||||
|
||||
Self& set_x(int value) { properties_.x = value; return *this; }
|
||||
Self& set_y(int value) { properties_.y = value; return *this; }
|
||||
Self& set_orientation(Orientation value) { properties_.orientation = value; return *this; }
|
||||
@@ -32,7 +25,6 @@ public:
|
||||
Self& set_unit_text_pen(Pen value) { properties_.unit_text_pen = value; return *this; }
|
||||
Self& set_unit_text_background_brush(Brush value) { properties_.unit_text_background_brush = value; return *this; }
|
||||
Self& set_label_rotation_degrees(int value) { properties_.label_rotation_degrees = value; return *this; }
|
||||
|
||||
Self& set_coord_range(Range value) requires requires(Properties properties) { properties.coordinates = value; } {
|
||||
properties_.coordinates = value;
|
||||
return *this;
|
||||
@@ -69,21 +61,20 @@ public:
|
||||
properties_.newest_at_start = value;
|
||||
return *this;
|
||||
}
|
||||
|
||||
std::shared_ptr<Product> build() const {
|
||||
renderive_Owner<Product> build() const {
|
||||
if (!parent_)
|
||||
return {};
|
||||
auto result = parent_->scene().template make_renderable<Product>(properties_);
|
||||
parent_->scene().attach_renderable(result, {
|
||||
.display_parents = {parent_},
|
||||
.dependency_parents = {parent_}
|
||||
});
|
||||
auto result = renderive_Owner<Product>::make(properties_);
|
||||
if (attach_builder_) {
|
||||
attach_builder_->attach(result);
|
||||
attach_builder_->add_parent(::Scene_Base::Relationship::display, result, parent_);
|
||||
attach_builder_->add_parent(::Scene_Base::Relationship::dependency, result, parent_);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private:
|
||||
std::shared_ptr<Renderable> parent_;
|
||||
renderive_Owner<Renderable> parent_;
|
||||
Properties properties_;
|
||||
::Scene_Base::Attach_Builder* attach_builder_{};
|
||||
};
|
||||
|
||||
} // namespace renderive::detail
|
||||
}
|
||||
|
||||
@@ -25,10 +25,9 @@ class Axis_State_Strategy
|
||||
using Base = Double_State_Strategy<Abs_Axis, State, Atomic_Spin_Mutex, State_Observer>;
|
||||
|
||||
public:
|
||||
Axis_State_Strategy(::Scene_Base& scene, State state)
|
||||
explicit Axis_State_Strategy(State state)
|
||||
: Base(state,
|
||||
With_Observer<State_Observer>{State_Observer(Renderable_State_Observer(this))},
|
||||
scene) {}
|
||||
With_Observer<State_Observer>{State_Observer(Renderable_State_Observer(this))}) {}
|
||||
|
||||
template <auto Member, Property_Member_Assignable<State, Member> Value>
|
||||
Axis_State_Strategy& set(Value&& value) {
|
||||
|
||||
@@ -6,8 +6,8 @@
|
||||
|
||||
namespace renderive::detail {
|
||||
|
||||
Frequency_Axis_Control::Frequency_Axis_Control(::Scene_Base& scene, const Axis_Properties& properties)
|
||||
: Axis(scene, properties) {}
|
||||
Frequency_Axis_Control::Frequency_Axis_Control(const Axis_Properties& properties)
|
||||
: Axis(properties) {}
|
||||
|
||||
std::string Frequency_Axis_Control::format_tick_label(double tick,
|
||||
const Axis_Properties& state) const {
|
||||
|
||||
@@ -8,7 +8,7 @@ namespace detail {
|
||||
|
||||
class LIB_DECL Frequency_Axis_Control : public Axis {
|
||||
public:
|
||||
Frequency_Axis_Control(::Scene_Base& scene, const Axis_Properties& properties);
|
||||
explicit Frequency_Axis_Control(const Axis_Properties& properties);
|
||||
protected:
|
||||
[[nodiscard]] std::string format_tick_label(double tick, const Axis_Properties& state) const override;
|
||||
};
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
|
||||
namespace renderive::detail {
|
||||
|
||||
Axis_Control::Axis_Control(::Scene_Base& scene, const Axis_Properties& properties)
|
||||
: Axis_State_Strategy(scene, properties) {}
|
||||
Axis_Control::Axis_Control(const Axis_Properties& properties)
|
||||
: Axis_State_Strategy(properties) {}
|
||||
|
||||
void Axis_Control::handle_event(const Event& event) {
|
||||
if (event.type == Event_Type::Wheel && get<&Axis_Properties::wheel>()) {
|
||||
|
||||
@@ -34,7 +34,7 @@ struct Axis_Interaction_State {
|
||||
|
||||
class LIB_DECL Axis_Control : public Axis_State_Strategy<Axis_Properties>, public Event_Handler {
|
||||
public:
|
||||
Axis_Control(::Scene_Base& scene, const Axis_Properties& properties);
|
||||
explicit Axis_Control(const Axis_Properties& properties);
|
||||
void handle_event(const Event& event) override;
|
||||
|
||||
void publish() override;
|
||||
|
||||
@@ -16,8 +16,8 @@ Time_Axis_State time_state_from(const Time_Axis_Properties& properties) {
|
||||
|
||||
} // namespace
|
||||
|
||||
Time_Axis_Control::Time_Axis_Control(::Scene_Base& scene, const Time_Axis_Properties& properties)
|
||||
: Axis_State_Strategy(scene, time_state_from(properties)) {}
|
||||
Time_Axis_Control::Time_Axis_Control(const Time_Axis_Properties& properties)
|
||||
: Axis_State_Strategy(time_state_from(properties)) {}
|
||||
|
||||
std::size_t Time_Axis_Control::time_point_count() const {
|
||||
return read([](const Time_Axis_State& state) { return state.samples.size(); });
|
||||
|
||||
@@ -27,7 +27,7 @@ struct Time_Axis_State : Time_Axis_Properties {
|
||||
|
||||
class LIB_DECL Time_Axis_Control : public Axis_State_Strategy<Time_Axis_State> {
|
||||
public:
|
||||
Time_Axis_Control(::Scene_Base& scene, const Time_Axis_Properties& properties);
|
||||
explicit Time_Axis_Control(const Time_Axis_Properties& properties);
|
||||
[[nodiscard]] std::size_t time_point_count() const;
|
||||
int append_time(Time_Of_Day time);
|
||||
[[nodiscard]] Time_Of_Day tick_to_time(int tick) const;
|
||||
|
||||
Reference in New Issue
Block a user