#pragma once #include "Abs_Axis.h" #include "../base/Time_Of_Day.h" #include #include namespace renderive { struct Time_Axis_Private; struct Time_Axis_Render_Access; class Timeline_Stream; /// 时间轴,输入 tick 后按格式显示时间标签。 class LIB_DECL Time_Axis : public Abs_Axis { public: /// 返回私有渲染数据。 Render_Object_Owner create_render_data() override; Render_Object_Owner create_render_state() override; Render_Object_Owner create_input_data() override; Time_Axis(); PROP(int, visible_time_point_count) PROP(int, tick_label_spacing_px) PROP(std::string, time_format) PROP(Font, font) PROP(std::shared_ptr, timeline_stream) PROP(bool, newest_at_axis_start) /// 推入一个新的时间点并返回对应 tick。 int append_time(Time_Of_Day time); /// 将 tick 转换成时间。 Time_Of_Day tick_to_time(int tick); struct Builder; private: friend struct Time_Axis_Render_Access; Time_Axis_Private* d(); }; struct Time_Axis_Prop { int visible_time_point_count = 100; int tick_label_spacing_px = 8; std::string time_format = "mm:ss.zzz"; Font font; std::shared_ptr timeline_stream; bool newest_at_axis_start = false; }; struct LIB_DECL Time_Axis::Builder : Abs_Axis::Builder_T, public Time_Axis_Prop { PROP_B(int, visible_time_point_count) PROP_B(int, tick_label_spacing_px) PROP_B(std::string, time_format) PROP_B(Font, font) PROP_B(std::shared_ptr, timeline_stream) PROP_B(bool, newest_at_axis_start) /// 创建时间轴构造器。 Builder(std::shared_ptr parent, Orientation orientation); /// 构建并返回时间轴对象。 std::shared_ptr build(); }; } // namespace renderive