画廊添加

This commit is contained in:
2026-08-08 16:06:36 +08:00
parent 989ad91b69
commit b21043e3b8
17 changed files with 1008 additions and 170 deletions
@@ -8,10 +8,12 @@ namespace adminive {
enum class Composition_Node_Kind {
slot,
heading,
frontend,
vertical,
horizontal,
flow,
grid,
list,
group,
card,
tabs,
@@ -77,6 +79,10 @@ Composition_Node make_container(Composition_Node_Kind kind, Children&&... childr
return result;
}
template <class... Children>
Composition_Node frontend(Children&&... children) {
return make_container(Composition_Node_Kind::frontend, std::forward<Children>(children)...);
}
template <class... Children>
Composition_Node vertical(Children&&... children) {
return make_container(Composition_Node_Kind::vertical, std::forward<Children>(children)...);
}
@@ -95,6 +101,10 @@ Composition_Node grid(std::size_t columns, Children&&... children) {
return result;
}
template <class... Children>
Composition_Node list(Children&&... children) {
return make_container(Composition_Node_Kind::list, std::forward<Children>(children)...);
}
template <class... Children>
Composition_Node group(std::string title, Children&&... children) {
auto result = make_container(Composition_Node_Kind::group, std::forward<Children>(children)...);
result.title = std::move(title);
@@ -130,13 +140,16 @@ struct Composition_View {
inline Composition_View composition_view(std::string name, Composition_Node body) {
return Composition_View{std::move(name), {}, std::move(body)};
}
inline void validate_composition_node(const Composition_Node& node) {
inline void validate_composition_node_impl(const Composition_Node& node, bool tab_allowed) {
if(node.kind == Composition_Node_Kind::slot && node.slot.empty()) {
throw std::invalid_argument("composition slot name must not be empty");
}
if(node.kind == Composition_Node_Kind::grid && node.columns == 0) {
throw std::invalid_argument("composition grid requires at least one column");
}
if(node.kind == Composition_Node_Kind::tab && !tab_allowed) {
throw std::invalid_argument("composition tab can only be used inside tabs");
}
if(node.kind == Composition_Node_Kind::tabs) {
for(const auto& child : node.children) {
if(child.kind != Composition_Node_Kind::tab) {
@@ -145,9 +158,12 @@ inline void validate_composition_node(const Composition_Node& node) {
}
}
for(const auto& child : node.children) {
validate_composition_node(child);
validate_composition_node_impl(child, node.kind == Composition_Node_Kind::tabs);
}
}
inline void validate_composition_node(const Composition_Node& node) {
validate_composition_node_impl(node, false);
}
inline void validate_composition_view(const Composition_View& view) {
if(view.name.empty()) {
throw std::invalid_argument("composition view name must not be empty");