dummy layout component and system

This commit is contained in:
BlackMATov
2020-02-07 04:10:06 +07:00
parent 729a1f98db
commit 5a64cedd92
11 changed files with 278 additions and 0 deletions

View File

@@ -37,6 +37,7 @@
#include "components/events.hpp"
#include "components/flipbook_player.hpp"
#include "components/label.hpp"
#include "components/layout.hpp"
#include "components/model_renderer.hpp"
#include "components/named.hpp"
#include "components/renderer.hpp"
@@ -50,6 +51,7 @@
#include "systems/frame_system.hpp"
#include "systems/gizmos_system.hpp"
#include "systems/label_system.hpp"
#include "systems/layout_system.hpp"
#include "systems/render_system.hpp"
#include "systems/script_system.hpp"
#include "systems/spine_system.hpp"

View File

@@ -57,6 +57,7 @@ namespace e2d
class events;
class flipbook_player;
class label;
class layout;
class model_renderer;
class named;
class renderer;
@@ -70,6 +71,7 @@ namespace e2d
class frame_system;
class gizmos_system;
class label_system;
class layout_system;
class render_system;
class script_system;
class spine_system;

View File

@@ -0,0 +1,76 @@
/*******************************************************************************
* This file is part of the "Enduro2D"
* For conditions of distribution and use, see copyright notice in LICENSE.md
* Copyright (C) 2018-2020, by Matvey Cherevko (blackmatov@gmail.com)
******************************************************************************/
#pragma once
#include "_components.hpp"
namespace e2d
{
class layout final {
public:
layout() = default;
};
class layout_item final {
public:
layout_item() = default;
};
}
namespace e2d
{
template <>
class factory_loader<layout> final : factory_loader<> {
public:
static const char* schema_source;
bool operator()(
layout& component,
const fill_context& ctx) const;
bool operator()(
asset_dependencies& dependencies,
const collect_context& ctx) const;
};
template <>
class factory_loader<layout_item> final : factory_loader<> {
public:
static const char* schema_source;
bool operator()(
layout_item& component,
const fill_context& ctx) const;
bool operator()(
asset_dependencies& dependencies,
const collect_context& ctx) const;
};
}
namespace e2d
{
template <>
class component_inspector<layout> final : component_inspector<> {
public:
static const char* title;
void operator()(gcomponent<layout>& c) const;
};
template <>
class component_inspector<layout_item> final : component_inspector<> {
public:
static const char* title;
void operator()(gcomponent<layout_item>& c) const;
};
}
namespace e2d
{
}

View File

@@ -0,0 +1,26 @@
/*******************************************************************************
* This file is part of the "Enduro2D"
* For conditions of distribution and use, see copyright notice in LICENSE.md
* Copyright (C) 2018-2020, by Matvey Cherevko (blackmatov@gmail.com)
******************************************************************************/
#pragma once
#include "_systems.hpp"
namespace e2d
{
class layout_system final
: public ecs::system<ecs::after<systems::update_event>> {
public:
layout_system();
~layout_system() noexcept final;
void process(
ecs::registry& owner,
const ecs::after<systems::update_event>& trigger) override;
private:
class internal_state;
std::unique_ptr<internal_state> state_;
};
}

View File

@@ -0,0 +1,13 @@
---@class layout
local layout = {
}
---@class layout_item
local layout_item = {
}
---@type layout
_G.layout = _G.layout or layout
---@type layout_item
_G.layout_item = _G.layout_item or layout_item

View File

@@ -30,6 +30,12 @@ local gobject = {
---@type label
label = nil,
---@type layout
layout = nil,
---@type layout_item
layout_item = nil,
---@type model_renderer
model_renderer = nil,

View File

@@ -24,6 +24,7 @@ namespace e2d::bindings::high
void bind_colliders(sol::state& l);
void bind_flipbook_player(sol::state& l);
void bind_label(sol::state& l);
void bind_layout(sol::state& l);
void bind_model_renderer(sol::state& l);
void bind_named(sol::state& l);
void bind_renderer(sol::state& l);
@@ -50,6 +51,7 @@ namespace e2d::bindings
high::bind_colliders(l);
high::bind_flipbook_player(l);
high::bind_label(l);
high::bind_layout(l);
high::bind_model_renderer(l);
high::bind_named(l);
high::bind_renderer(l);

View File

@@ -0,0 +1,23 @@
/*******************************************************************************
* This file is part of the "Enduro2D"
* For conditions of distribution and use, see copyright notice in LICENSE.md
* Copyright (C) 2018-2020, by Matvey Cherevko (blackmatov@gmail.com)
******************************************************************************/
#include "../_high_binds.hpp"
#include <enduro2d/high/gobject.hpp>
#include <enduro2d/high/components/layout.hpp>
namespace e2d::bindings::high
{
void bind_layout(sol::state& l) {
l.new_usertype<gcomponent<layout>>("layout",
sol::no_constructor
);
l.new_usertype<gcomponent<layout_item>>("layout_item",
sol::no_constructor
);
}
}

View File

@@ -0,0 +1,77 @@
/*******************************************************************************
* This file is part of the "Enduro2D"
* For conditions of distribution and use, see copyright notice in LICENSE.md
* Copyright (C) 2018-2020, by Matvey Cherevko (blackmatov@gmail.com)
******************************************************************************/
#include <enduro2d/high/components/layout.hpp>
namespace e2d
{
const char* factory_loader<layout>::schema_source = R"json({
"type" : "object",
"required" : [],
"additionalProperties" : false,
"properties" : {}
})json";
bool factory_loader<layout>::operator()(
layout& component,
const fill_context& ctx) const
{
E2D_UNUSED(component, ctx);
return true;
}
bool factory_loader<layout>::operator()(
asset_dependencies& dependencies,
const collect_context& ctx) const
{
E2D_UNUSED(dependencies, ctx);
return true;
}
}
namespace e2d
{
const char* factory_loader<layout_item>::schema_source = R"json({
"type" : "object",
"required" : [],
"additionalProperties" : false,
"properties" : {}
})json";
bool factory_loader<layout_item>::operator()(
layout_item& component,
const fill_context& ctx) const
{
E2D_UNUSED(component, ctx);
return true;
}
bool factory_loader<layout_item>::operator()(
asset_dependencies& dependencies,
const collect_context& ctx) const
{
E2D_UNUSED(dependencies, ctx);
return true;
}
}
namespace e2d
{
const char* component_inspector<layout>::title = ICON_FA_BARS " layout";
void component_inspector<layout>::operator()(gcomponent<layout>& c) const {
E2D_UNUSED(c);
}
}
namespace e2d
{
const char* component_inspector<layout_item>::title = ICON_FA_GRIP_LINES " layout_item";
void component_inspector<layout_item>::operator()(gcomponent<layout_item>& c) const {
E2D_UNUSED(c);
}
}

View File

@@ -22,6 +22,7 @@
#include <enduro2d/high/components/events.hpp>
#include <enduro2d/high/components/flipbook_player.hpp>
#include <enduro2d/high/components/label.hpp>
#include <enduro2d/high/components/layout.hpp>
#include <enduro2d/high/components/model_renderer.hpp>
#include <enduro2d/high/components/named.hpp>
#include <enduro2d/high/components/renderer.hpp>
@@ -35,6 +36,7 @@
#include <enduro2d/high/systems/frame_system.hpp>
#include <enduro2d/high/systems/gizmos_system.hpp>
#include <enduro2d/high/systems/label_system.hpp>
#include <enduro2d/high/systems/layout_system.hpp>
#include <enduro2d/high/systems/render_system.hpp>
#include <enduro2d/high/systems/script_system.hpp>
#include <enduro2d/high/systems/spine_system.hpp>
@@ -69,6 +71,8 @@ namespace
.add_system<gizmos_system>())
.feature<struct label_feature>(ecs::feature()
.add_system<label_system>())
.feature<struct layout_feature>(ecs::feature()
.add_system<layout_system>())
.feature<struct render_feature>(ecs::feature()
.add_system<render_system>())
.feature<struct script_feature>(ecs::feature()
@@ -193,6 +197,8 @@ namespace e2d
.register_component<flipbook_player>("flipbook_player")
.register_component<label>("label")
.register_component<label::dirty>("label.dirty")
.register_component<layout>("layout")
.register_component<layout_item>("layout_item")
.register_component<model_renderer>("model_renderer")
.register_component<named>("named")
.register_component<renderer>("renderer")
@@ -217,6 +223,8 @@ namespace e2d
.register_component<flipbook_player>("flipbook_player")
.register_component<label>("label")
//.register_component<label::dirty>("label.dirty")
.register_component<layout>("layout")
.register_component<layout_item>("layout_item")
.register_component<model_renderer>("model_renderer")
.register_component<named>("named")
.register_component<renderer>("renderer")

View File

@@ -0,0 +1,43 @@
/*******************************************************************************
* This file is part of the "Enduro2D"
* For conditions of distribution and use, see copyright notice in LICENSE.md
* Copyright (C) 2018-2020, by Matvey Cherevko (blackmatov@gmail.com)
******************************************************************************/
#include <enduro2d/high/systems/layout_system.hpp>
#include <enduro2d/high/components/layout.hpp>
namespace e2d
{
//
// layout_system::internal_state
//
class layout_system::internal_state final : private noncopyable {
public:
internal_state() = default;
~internal_state() noexcept = default;
void process_update(ecs::registry& owner) {
E2D_UNUSED(owner);
}
};
//
// layout_system
//
layout_system::layout_system()
: state_(new internal_state()) {}
layout_system::~layout_system() noexcept = default;
void layout_system::process(
ecs::registry& owner,
const ecs::after<systems::update_event>& trigger)
{
E2D_UNUSED(trigger);
E2D_PROFILER_SCOPE("layout_system.process_update");
state_->process_update(owner);
}
}