修复若干bug
This commit is contained in:
@@ -20,12 +20,9 @@
|
||||
#include <string>
|
||||
#include <type_traits>
|
||||
#include <vector>
|
||||
|
||||
namespace renderive {
|
||||
|
||||
class Plot_Core;
|
||||
class Renderable;
|
||||
|
||||
struct Renderable_Tree_Node {
|
||||
std::shared_ptr<Renderable> renderable;
|
||||
std::size_t subtree_end{};
|
||||
@@ -34,9 +31,7 @@ struct Renderable_Tree_Node {
|
||||
std::string cache_parent_object_name;
|
||||
int cache_tree_depth{};
|
||||
};
|
||||
|
||||
using Renderable_Tree_Snapshot = std::vector<Renderable_Tree_Node>;
|
||||
|
||||
template <typename T>
|
||||
concept Render_State_Type = std::derived_from<T, Render_State> && std::is_copy_assignable_v<T>;
|
||||
template <typename T>
|
||||
@@ -46,8 +41,7 @@ concept Render_Data_Type = std::derived_from<T, Render_Data>;
|
||||
template <typename Owner, Render_Data_Type Data, Render_State_Type State, Input_Data_Type Input>
|
||||
struct Renderable_Binding;
|
||||
template <typename That>
|
||||
struct Hover_Info_Renderable;
|
||||
|
||||
struct Hover_Tooltip_Mixin;
|
||||
class Renderable : public std::enable_shared_from_this<Renderable> {
|
||||
public:
|
||||
virtual Render_Object_Owner create_render_data() {
|
||||
@@ -59,23 +53,18 @@ public:
|
||||
virtual Render_Object_Owner create_input_data() {
|
||||
return make_render_object<Input_Data>();
|
||||
}
|
||||
|
||||
virtual void init(const std::shared_ptr<Renderable>& parent);
|
||||
virtual void init_root(Plot_Core* plot);
|
||||
|
||||
void add_child(const std::shared_ptr<Renderable>& child);
|
||||
void remove_child(const std::shared_ptr<Renderable>& child);
|
||||
|
||||
std::vector<std::shared_ptr<Renderable>> children_snapshot() const;
|
||||
std::vector<std::shared_ptr<Renderable>> hit_renderables(const PointF& pos);
|
||||
void append_tree_snapshot(Renderable_Tree_Snapshot& snapshot, const std::string& parent_object_name = {}, int render_tree_depth = 0, const std::string& cache_parent_object_name = {}, int cache_tree_depth = 0);
|
||||
|
||||
void render(Canvas& canvas, const Plot_Render_Snapshot& snapshot);
|
||||
void render_tree_snapshot(Canvas& canvas, const Plot_Render_Snapshot& snapshot, const Renderable_Tree_Snapshot& tree, std::size_t index);
|
||||
void draw(Canvas& canvas, const Plot_Render_Snapshot& snapshot);
|
||||
void prepare_data(const Plot_Render_Snapshot& snapshot);
|
||||
bool select_test(const PointF& pos);
|
||||
|
||||
void plot_event(const Event& event);
|
||||
void mouse_press_event(const Pointer_Event& event);
|
||||
void mouse_move_event(const Pointer_Event& event);
|
||||
@@ -85,7 +74,6 @@ public:
|
||||
void key_release_event(const Key_Event& event);
|
||||
void resize_event(const Resize_Event& event);
|
||||
void wheel_event(const Wheel_Event& event);
|
||||
|
||||
Renderable_Cache_Mode get_cache_mode() const;
|
||||
void set_cache_mode(Renderable_Cache_Mode mode);
|
||||
[[nodiscard]] bool attached_to_plot() const;
|
||||
@@ -96,24 +84,19 @@ public:
|
||||
void set_visible(bool value);
|
||||
[[nodiscard]] bool should_prepare() const;
|
||||
void detach_from_parent();
|
||||
|
||||
std::string cache_parent_object_name() const;
|
||||
int cache_tree_depth() const;
|
||||
std::string render_parent_object_name() const;
|
||||
int render_tree_depth() const;
|
||||
|
||||
void mark_render_dirty();
|
||||
|
||||
[[nodiscard]] bool ok() const;
|
||||
[[nodiscard]] bool get_retiring() const;
|
||||
virtual ~Renderable();
|
||||
|
||||
private:
|
||||
template <typename Owner, Render_Data_Type Data, Render_State_Type State, Input_Data_Type Input>
|
||||
friend struct Renderable_Binding;
|
||||
template <typename That>
|
||||
friend struct Hover_Info_Renderable;
|
||||
|
||||
friend struct Hover_Tooltip_Mixin;
|
||||
Render_Object_Owner d_owner;
|
||||
Render_Data* d_ptr{};
|
||||
Plot_Core* plot{};
|
||||
@@ -131,7 +114,6 @@ private:
|
||||
Rect cache_bounds;
|
||||
std::atomic_bool retiring{true};
|
||||
std::atomic_bool initialized{false};
|
||||
|
||||
void init_common(Plot_Core* plot);
|
||||
void render_direct(Canvas& canvas, const Plot_Render_Snapshot& snapshot);
|
||||
void render_cached(Canvas& canvas, const Plot_Render_Snapshot& snapshot);
|
||||
@@ -146,5 +128,4 @@ private:
|
||||
void append_hit_renderables(std::vector<std::shared_ptr<Renderable>>& hits, const PointF& pos);
|
||||
void detach_from_plot_tree();
|
||||
};
|
||||
|
||||
} // namespace renderive
|
||||
|
||||
Reference in New Issue
Block a user