fix run and examples folred
This commit is contained in:
24
bin/layers/meson.build
Executable file
24
bin/layers/meson.build
Executable file
@@ -0,0 +1,24 @@
|
||||
inc += include_directories('.')
|
||||
|
||||
headers = [
|
||||
'ui_layer/ui_layer.hpp',
|
||||
'ui_layer_double/ui_layer_double.hpp',
|
||||
]
|
||||
|
||||
sources = [
|
||||
'ui_layer/ui_layer.cpp',
|
||||
'ui_layer_double/ui_layer_double.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,
|
||||
)
|
||||
113
bin/layers/ui_layer/ui_layer.cpp
Executable file
113
bin/layers/ui_layer/ui_layer.cpp
Executable file
@@ -0,0 +1,113 @@
|
||||
#include "ui_layer.hpp"
|
||||
|
||||
#include "utils.hpp"
|
||||
|
||||
namespace example
|
||||
{
|
||||
void ui_layer::on_attach()
|
||||
{
|
||||
CONNECT(this);
|
||||
|
||||
hack::log()("on_attach");
|
||||
}
|
||||
|
||||
void ui_layer::on_detach()
|
||||
{
|
||||
DISCONNECT();
|
||||
hack::log()("on_detach");
|
||||
}
|
||||
|
||||
void ui_layer::render()
|
||||
{
|
||||
VE_PUSH_FONT(REGULAR, 30);
|
||||
if (ImGui::BeginMainMenuBar())
|
||||
{
|
||||
if (ImGui::BeginMenu("File"))
|
||||
{
|
||||
if (ImGui::MenuItem("New")) {}
|
||||
if (ImGui::MenuItem("Open", "Ctrl+O")) {}
|
||||
ImGui::EndMenu();
|
||||
}
|
||||
if (ImGui::BeginMenu("Edit"))
|
||||
{
|
||||
if (ImGui::MenuItem("Undo", "CTRL+Z")) {}
|
||||
if (ImGui::MenuItem("Redo", "CTRL+Y", false, false)) {} // Disabled item
|
||||
ImGui::Separator();
|
||||
if (ImGui::MenuItem("Cut", "CTRL+X")) {}
|
||||
if (ImGui::MenuItem("Copy", "CTRL+C")) {}
|
||||
if (ImGui::MenuItem("Paste", "CTRL+V")) {}
|
||||
ImGui::EndMenu();
|
||||
}
|
||||
ImGui::EndMainMenuBar();
|
||||
}
|
||||
|
||||
ImGui::SetNextWindowPos(m_pos);
|
||||
ImGui::SetNextWindowSize(m_size);
|
||||
|
||||
if (!ImGui::Begin(VE_NO_NAME("Test signal"), nullptr, m_win_flags)) ImGui::End();
|
||||
|
||||
if (ImGui::Button("Test signal", ImVec2(128, 130)))
|
||||
{
|
||||
VE::event e { test_event::TEST_EVEN_1, std::string("test event 1 message"), "asdf-asdf-asdf" };
|
||||
EMIT(e);
|
||||
auto r = e.get_result<std::string>();
|
||||
hack::log()(r);
|
||||
|
||||
e = { test_event::TEST_EVEN_2, std::string("test event 2 message") };
|
||||
EMIT(e);
|
||||
r = e.get_result<std::string>();
|
||||
hack::log()(r);
|
||||
}
|
||||
|
||||
ImPlot::ShowDemoWindow();
|
||||
ImPlot3D::ShowDemoWindow();
|
||||
ImGui::ShowDemoWindow();
|
||||
|
||||
ImGui::TextDisabled("asdfasdf");
|
||||
|
||||
if (ImGui::BeginTable("table1", 3))
|
||||
{
|
||||
for (int row = 0; row < 4; row++)
|
||||
{
|
||||
ImGui::TableNextRow();
|
||||
for (int column = 0; column < 3; column++)
|
||||
{
|
||||
ImGui::TableSetColumnIndex(column);
|
||||
ImGui::Text("Row %d Column %d", row, column);
|
||||
}
|
||||
}
|
||||
ImGui::EndTable();
|
||||
}
|
||||
|
||||
|
||||
VE_POP_FONT();
|
||||
ImGui::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_1)
|
||||
{
|
||||
hack::log()(std::any_cast<std::string>(e.m_data));
|
||||
e.m_result = std::string("test_event_1");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ui_layer::update()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
17
bin/layers/ui_layer/ui_layer.hpp
Executable file
17
bin/layers/ui_layer/ui_layer.hpp
Executable file
@@ -0,0 +1,17 @@
|
||||
#pragma once
|
||||
|
||||
#include <VE.hpp>
|
||||
|
||||
namespace example
|
||||
{
|
||||
class ui_layer : public VE::layer, public VE::flags, public VE::connector
|
||||
{
|
||||
VE_OVERIDE();
|
||||
VE_EVENT_OVERIDE();
|
||||
|
||||
ImVec2 m_size = ImVec2{ 1200.f, 400.f };
|
||||
ImVec2 m_pos = ImVec2{ 1200.f, 400.f };
|
||||
std::string m_key;
|
||||
};
|
||||
}
|
||||
|
||||
73
bin/layers/ui_layer_double/ui_layer_double.cpp
Executable file
73
bin/layers/ui_layer_double/ui_layer_double.cpp
Executable file
@@ -0,0 +1,73 @@
|
||||
#include "ui_layer_double.hpp"
|
||||
|
||||
#include "utils.hpp"
|
||||
|
||||
namespace example
|
||||
{
|
||||
void ui_layer_double::on_attach()
|
||||
{
|
||||
CONNECT(this);
|
||||
|
||||
hack::log()("on_attach");
|
||||
|
||||
m_win_flags &= ~ImGuiWindowFlags_NoTitleBar;
|
||||
}
|
||||
|
||||
void ui_layer_double::on_detach()
|
||||
{
|
||||
DISCONNECT();
|
||||
hack::log()("on_detach");
|
||||
}
|
||||
|
||||
void ui_layer_double::render()
|
||||
{
|
||||
ImGui::SetNextWindowPos(ImVec2{ 100.f, 800.f });
|
||||
ImGui::SetNextWindowSize(m_size);
|
||||
|
||||
if (!ImGui::Begin(VE_NAME("Test signal_double"), nullptr, m_win_flags)) ImGui::End();
|
||||
|
||||
VE_PUSH_FONT(REGULAR, 20);
|
||||
if (ImGui::Button("Test signal_double", ImVec2(128, 130)))
|
||||
{
|
||||
VE::event e { test_event::TEST_EVEN_2, std::string("test event message ui_layer_double") };
|
||||
EMIT(e);
|
||||
}
|
||||
|
||||
if (ImGui::Button("Test on_detach", ImVec2(128, 130))) on_detach();
|
||||
if (ImGui::Button("Test on_attach", ImVec2(128, 130))) on_attach();
|
||||
VE_POP_FONT();
|
||||
|
||||
VE_PUSH_FONT(ICON, 12);
|
||||
ImGui::Button(VE::style::icon::ICON_ALIGN_RIGHT, ImVec2{20, 20});
|
||||
VE_POP_FONT();
|
||||
|
||||
ImGui::End();
|
||||
}
|
||||
|
||||
void ui_layer_double::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_2)
|
||||
{
|
||||
hack::log()(std::any_cast<std::string>(e.m_data));
|
||||
e.m_result = std::string("test_event_2");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ui_layer_double::update()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
17
bin/layers/ui_layer_double/ui_layer_double.hpp
Executable file
17
bin/layers/ui_layer_double/ui_layer_double.hpp
Executable file
@@ -0,0 +1,17 @@
|
||||
#pragma once
|
||||
|
||||
#include <VE.hpp>
|
||||
|
||||
namespace example
|
||||
{
|
||||
class ui_layer_double : public VE::layer, public VE::flags, public VE::connector
|
||||
{
|
||||
VE_OVERIDE();
|
||||
VE_EVENT_OVERIDE();
|
||||
|
||||
ImVec2 m_size = ImVec2{ 800.f, 800.f };
|
||||
ImVec2 m_pos = ImVec2{ 400.f, 400.f };
|
||||
std::string m_key;
|
||||
};
|
||||
}
|
||||
|
||||
10
bin/layers/utils.hpp
Normal file
10
bin/layers/utils.hpp
Normal file
@@ -0,0 +1,10 @@
|
||||
#pragma once
|
||||
|
||||
namespace example
|
||||
{
|
||||
enum class test_event
|
||||
{
|
||||
TEST_EVEN_1,
|
||||
TEST_EVEN_2
|
||||
};
|
||||
}
|
||||
23
bin/main.cpp
Executable file
23
bin/main.cpp
Executable file
@@ -0,0 +1,23 @@
|
||||
#include "layers/ui_layer/ui_layer.hpp"
|
||||
#include "layers/ui_layer_double/ui_layer_double.hpp"
|
||||
|
||||
namespace example
|
||||
{
|
||||
class app : public VE::application
|
||||
{
|
||||
public:
|
||||
app(std::string app_name) : VE::application{ app_name } {};
|
||||
~app() = default;
|
||||
};
|
||||
}
|
||||
|
||||
auto main(int argc, char* args[]) -> int
|
||||
{
|
||||
example::app app{ "vertex_engine_sandbox" };
|
||||
|
||||
app.push_layer(
|
||||
new example::ui_layer{},
|
||||
new example::ui_layer_double{}
|
||||
);
|
||||
app.run();
|
||||
}
|
||||
6
bin/meson.build
Executable file
6
bin/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