Files
Renderive/render_2D/axis/Axis_Builder.h
T

81 lines
4.0 KiB
C++

#pragma once
#include "../renderable/Renderable.h"
#include "Axis_Types.h"
#include <renderive/scene/base/Scene_Base.hpp>
#include <utility>
namespace renderive::detail {
template <class Product, class Properties, class...>
class Axis_Renderable_Builder {
public:
using Self = Axis_Renderable_Builder;
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; }
Self& set_pixel_length(std::size_t value) { properties_.pixel_length = value; return *this; }
Self& set_tick_length(int value) { properties_.tick_length = value; return *this; }
Self& set_sub_tick_length(int value) { properties_.sub_tick_length = value; return *this; }
Self& set_color(Color value) { properties_.color = value; return *this; }
Self& set_locale(Number_Locale value) { properties_.locale = value; return *this; }
Self& set_unit_text(std::string value) { properties_.unit_text = std::move(value); return *this; }
Self& set_unit_text_font(Font value) { properties_.unit_text_font = value; return *this; }
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;
}
Self& set_label_precision(int value) requires requires(Properties properties) { properties.precision = value; } {
properties_.precision = value;
return *this;
}
Self& set_use_wheel(bool value) requires requires(Properties properties) { properties.wheel = value; } {
properties_.wheel = value;
return *this;
}
Self& set_use_drag(bool value) requires requires(Properties properties) { properties.drag = value; } {
properties_.drag = value;
return *this;
}
Self& set_visible_time_point_count(int value) requires requires(Properties properties) { properties.visible_count = value; } {
properties_.visible_count = value;
return *this;
}
Self& set_tick_label_spacing_px(int value) requires requires(Properties properties) { properties.tick_label_spacing_px = value; } {
properties_.tick_label_spacing_px = value;
return *this;
}
Self& set_time_format(std::string value) requires requires(Properties properties) { properties.format = value; } {
properties_.format = std::move(value);
return *this;
}
Self& set_font(Font value) requires requires(Properties properties) { properties.unit_text_font = value; } {
properties_.unit_text_font = value;
return *this;
}
Self& set_newest_at_axis_start(bool value) requires requires(Properties properties) { properties.newest_at_start = value; } {
properties_.newest_at_start = value;
return *this;
}
renderive_Owner<Product> build() const {
if (!parent_)
return {};
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:
renderive_Owner<Renderable> parent_;
Properties properties_;
::Scene_Base::Attach_Builder* attach_builder_{};
};
}