add new struct and events
This commit is contained in:
22
example/layers/meson.build
Executable file
22
example/layers/meson.build
Executable file
@@ -0,0 +1,22 @@
|
||||
inc += include_directories('.')
|
||||
|
||||
headers = [
|
||||
'ui_layer/ui_layer.hpp',
|
||||
]
|
||||
|
||||
sources = [
|
||||
'ui_layer/ui_layer.cpp',
|
||||
]
|
||||
|
||||
lib = library(
|
||||
'vertex_engine_sandbox',
|
||||
include_directories : inc,
|
||||
sources: [headers, sources],
|
||||
dependencies : deps,
|
||||
cpp_args: args
|
||||
)
|
||||
|
||||
deps += declare_dependency(
|
||||
include_directories: inc,
|
||||
link_with: lib,
|
||||
)
|
||||
46
example/layers/ui_layer/ui_layer.cpp
Executable file
46
example/layers/ui_layer/ui_layer.cpp
Executable file
@@ -0,0 +1,46 @@
|
||||
#include "ui_layer.hpp"
|
||||
|
||||
#include "utils.hpp"
|
||||
|
||||
namespace sandbox
|
||||
{
|
||||
void ui_layer::on_attach()
|
||||
{
|
||||
VE::CONNECT(this);
|
||||
|
||||
hack::log()("on_attach");
|
||||
}
|
||||
|
||||
void ui_layer::render()
|
||||
{
|
||||
// VE::WinPos(m_pos);
|
||||
// VE::WinSize(m_pos);
|
||||
|
||||
VE::Begin("name", m_pos, m_size, m_win_flags);
|
||||
VE::End();
|
||||
}
|
||||
|
||||
void ui_layer::on_event(VE::event e)
|
||||
{
|
||||
// для событий от перефирии
|
||||
// if (e.m_type.type() == typeid(VE::event_type))
|
||||
// {
|
||||
// auto t = std::any_cast<VE::event_type>(e.m_type);
|
||||
// if (t != VE::event_type::MOUSE_CURSOR_POSITION)
|
||||
// hack::log()((int)t);
|
||||
// }
|
||||
|
||||
if (e.m_type.type() == typeid(test_event))
|
||||
{
|
||||
auto t = std::any_cast<test_event>(e.m_type);
|
||||
if (t == test_event::TEST_EVEN)
|
||||
hack::log()(std::any_cast<std::string>(e.m_data));
|
||||
}
|
||||
}
|
||||
|
||||
void ui_layer::update()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
15
example/layers/ui_layer/ui_layer.hpp
Executable file
15
example/layers/ui_layer/ui_layer.hpp
Executable file
@@ -0,0 +1,15 @@
|
||||
#pragma once
|
||||
|
||||
#include <VE.hpp>
|
||||
|
||||
namespace sandbox
|
||||
{
|
||||
class ui_layer : public VE::layer, public VE::flags
|
||||
{
|
||||
VE_OVERIDE();
|
||||
|
||||
ImVec2 m_size = ImVec2{ 400.f, 400.f };
|
||||
ImVec2 m_pos = ImVec2{ 400.f, 400.f };
|
||||
};
|
||||
}
|
||||
|
||||
9
example/layers/utils.hpp
Normal file
9
example/layers/utils.hpp
Normal file
@@ -0,0 +1,9 @@
|
||||
#pragma once
|
||||
|
||||
namespace sandbox
|
||||
{
|
||||
enum class test_event
|
||||
{
|
||||
TEST_EVEN
|
||||
};
|
||||
}
|
||||
21
example/main.cpp
Executable file
21
example/main.cpp
Executable file
@@ -0,0 +1,21 @@
|
||||
#include "layers/ui_layer/ui_layer.hpp"
|
||||
|
||||
namespace sandbox
|
||||
{
|
||||
class app : public VE::application
|
||||
{
|
||||
public:
|
||||
app(std::string app_name) : VE::application{ app_name } {};
|
||||
~app() = default;
|
||||
};
|
||||
}
|
||||
|
||||
auto main(int argc, char* args[]) -> int
|
||||
{
|
||||
sandbox::app app{ "vertex_engine_sandbox" };
|
||||
|
||||
app.push_layer(
|
||||
new sandbox::ui_layer{}
|
||||
);
|
||||
app.run();
|
||||
}
|
||||
6
example/meson.build
Executable file
6
example/meson.build
Executable file
@@ -0,0 +1,6 @@
|
||||
executable(
|
||||
meson.project_name(),
|
||||
'main.cpp',
|
||||
dependencies : deps,
|
||||
cpp_args: args
|
||||
)
|
||||
Reference in New Issue
Block a user