dummy widget and widget system

This commit is contained in:
BlackMATov
2020-03-20 05:05:38 +07:00
parent 89e0bac901
commit cdd3007476
12 changed files with 326 additions and 2 deletions

View File

@@ -45,6 +45,7 @@
#include "components/spine_player.hpp"
#include "components/sprite_renderer.hpp"
#include "components/touchable.hpp"
#include "components/widget.hpp"
#include "systems/camera_system.hpp"
#include "systems/flipbook_system.hpp"

View File

@@ -65,6 +65,7 @@ namespace e2d
class spine_player;
class sprite_renderer;
class touchable;
class widget;
class camera_system;
class flipbook_system;

View File

@@ -0,0 +1,75 @@
/*******************************************************************************
* 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 widget final {
public:
widget() = default;
widget& size(const v2f& value) noexcept;
[[nodiscard]] const v2f& size() const noexcept;
widget& pivot(const v2f& value) noexcept;
[[nodiscard]] const v2f& pivot() const noexcept;
private:
v2f size_ = v2f::zero();
v2f pivot_ = v2f::unit() * 0.5f;
};
}
namespace e2d
{
template <>
class factory_loader<widget> final : factory_loader<> {
public:
static const char* schema_source;
bool operator()(
widget& component,
const fill_context& ctx) const;
bool operator()(
asset_dependencies& dependencies,
const collect_context& ctx) const;
};
}
namespace e2d
{
template <>
class component_inspector<widget> final : component_inspector<> {
public:
static const char* title;
void operator()(gcomponent<widget>& c) const;
};
}
namespace e2d
{
inline widget& widget::size(const v2f& value) noexcept {
size_ = value;
return *this;
}
inline const v2f& widget::size() const noexcept {
return size_;
}
inline widget& widget::pivot(const v2f& value) noexcept {
pivot_ = value;
return *this;
}
inline const v2f& widget::pivot() const noexcept {
return pivot_;
}
}

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 widget_system final
: public ecs::system<ecs::after<systems::update_event>> {
public:
widget_system();
~widget_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_;
};
}