mirror of
https://github.com/enduro2d/enduro2d.git
synced 2025-12-14 16:09:06 +07:00
dummy widget and widget system
This commit is contained in:
@@ -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"
|
||||
|
||||
@@ -65,6 +65,7 @@ namespace e2d
|
||||
class spine_player;
|
||||
class sprite_renderer;
|
||||
class touchable;
|
||||
class widget;
|
||||
|
||||
class camera_system;
|
||||
class flipbook_system;
|
||||
|
||||
75
headers/enduro2d/high/components/widget.hpp
Normal file
75
headers/enduro2d/high/components/widget.hpp
Normal 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_;
|
||||
}
|
||||
}
|
||||
26
headers/enduro2d/high/systems/widget_system.hpp
Normal file
26
headers/enduro2d/high/systems/widget_system.hpp
Normal 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_;
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user