#pragma once #include "Gallery_Session_Control.h" #include "Gallery_Renderables.h" #include #include namespace renderive::web::gallery_adminive { template auto callback_property(std::string name, std::string label, adminive::Field_Control control, Reader reader, Writer writer) { auto accessor = structive::trusted_callable_accessor( std::move(reader), std::move(writer)); static_assert(std::same_as); return adminive::field(std::move(name), std::move(label), std::move(accessor)) .editable() .unsynchronized() .control(control); } } // namespace renderive::web::gallery_adminive namespace adminive { template <> struct Type_Descriptor { static auto get() { using T = renderive::web::Gallery_Feedback_Policy; using namespace renderive::web::gallery_adminive; return adminive::object("feedback_policy", "Consumer feedback", boolean<&T::enabled>("enabled", "Enabled"), boolean<&T::pixel>("pixel", "Pixel feedback"), boolean<&T::presentation>("presentation", "Presentation feedback"), boolean<&T::manual>("manual", "Manual feedback"), number<&T::manual_fps>("manual_fps", "Manual FPS")); } }; template <> struct Type_Descriptor { static auto get() { using T = renderive::web::Gallery_Session_Control; using namespace renderive::web::gallery_adminive; const auto dirty = [](T& value) { value.plot_.notify_model_dirty(); }; return adminive::object("scene", "Scene", callback_property( "background_color", "Background", Field_Control::color, [](const T& value) { return value.plot_.background_color(); }, [dirty](T& value, renderive::Color color) { value.plot_.set_background_color(color); dirty(value); }), callback_property( "performance_overlay", "Performance overlay", Field_Control::boolean, [](const T& value) { const auto overlay = value.plot_.performance_overlay(); return overlay && overlay->enabled(); }, [dirty](T& value, bool enabled) { renderive::set_performance_overlay_enabled(value.plot_, enabled); dirty(value); }), callback_property( "renderable_visible", "Renderable visible", Field_Control::boolean, [](const T& value) { return value.renderable_.is_visible(); }, [dirty](T& value, bool visible) { value.renderable_.set_visible(visible); dirty(value); }), callback_property( "cache_mode", "Cache mode", Field_Control::select, [](const T& value) { return value.renderable_.get_cache_mode(); }, [dirty](T& value, renderive::Renderable_Cache_Mode mode) { value.renderable_.set_cache_mode(mode); dirty(value); }), callback_property( "object_name", "Object name", Field_Control::text, [](const T& value) { return value.renderable_.object_name(); }, [dirty](T& value, std::string name) { value.renderable_.set_object_name(std::move(name)); dirty(value); }), callback_property( "frequency_limit_enabled", "Frequency limit", Field_Control::boolean, [](const T& value) { return value.plot_.max_render_fps() > 0.0; }, [dirty](T& value, bool enabled) { if (enabled) { if (value.plot_.max_render_fps() <= 0.0) value.plot_.set_max_render_fps(30.0); } else { value.plot_.clear_max_render_fps(); } dirty(value); }), callback_property( "max_render_fps", "Maximum render FPS", Field_Control::number, [](const T& value) { const double fps = value.plot_.max_render_fps(); return fps > 0.0 ? fps : 30.0; }, [dirty](T& value, double fps) { if (value.plot_.max_render_fps() > 0.0) value.plot_.set_max_render_fps(fps); dirty(value); }), callback_property( "feedback", "Consumer feedback", Field_Control::automatic, [](const T& value) { return value.feedback_; }, [dirty](T& value, renderive::web::Gallery_Feedback_Policy feedback) { value.feedback_ = std::move(feedback); dirty(value); })); } }; static_assert(Described_Type); static_assert(Direct_Described_Object); } // namespace adminive