/* * Copyright 2023 jacqueline * * SPDX-License-Identifier: GPL-3.0-only */ #pragma once #include #include #include "lua.hpp" #include "lvgl.h" #include "service_locator.hpp" namespace lua { using LuaValue = std::variant; class Property { public: Property() : Property(std::monostate{}) {} Property(const LuaValue&); Property(const LuaValue&, std::function); auto IsTwoWay() -> bool { return cb_.has_value(); } auto PushValue(lua_State& s) -> int; auto PopValue(lua_State& s) -> bool; auto Update(const LuaValue& new_val) -> void; auto AddLuaBinding(lua_State*, int ref) -> void; private: LuaValue value_; std::optional> cb_; std::vector> bindings_; }; class PropertyBindings { public: PropertyBindings(lua_State&); auto Register(lua_State*, Property*) -> void; }; } // namespace lua