add try_engine
This commit is contained in:
78
src/rrr/layers/gui/browser/navigation/navigation.cpp
Normal file
78
src/rrr/layers/gui/browser/navigation/navigation.cpp
Normal file
@@ -0,0 +1,78 @@
|
||||
#include "navigation.hpp"
|
||||
|
||||
namespace rrr::layers::gui
|
||||
{
|
||||
void navigation::on_attach()
|
||||
{
|
||||
BASE_WINDOW_FLAGS();
|
||||
|
||||
data = cnt->get(TYPE_WIN::NAVIGATION);
|
||||
}
|
||||
|
||||
void navigation::on_detach()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void navigation::gui_render()
|
||||
{
|
||||
ImGui::SetNextWindowPos(ImVec2(pos_x, pos_y));
|
||||
ImGui::SetNextWindowSize(ImVec2(width, height));
|
||||
|
||||
BEGIN_IMGUI_WIN();
|
||||
|
||||
auto pos = ImGui::GetCursorPos();
|
||||
auto padding = -60.f;
|
||||
const ImVec4 type_color = ImVec4(0.35f, 0.35f, 0.35f, 1.0f);
|
||||
|
||||
// HERE начинаем тут
|
||||
// стилизуем ссылки
|
||||
// делаем навигацию
|
||||
for (auto& item : *data)
|
||||
{
|
||||
ImGui::PushID(item.id);
|
||||
|
||||
char buf[32];
|
||||
sprintf(buf, "##item_%d", item.id);
|
||||
|
||||
ImGui::SetCursorPos(ImVec2(pos.x, pos.y + padding));
|
||||
if (ImGui::Selectable(buf, item.id == selected, 0, ImVec2(width, 60)))
|
||||
selected = item.id;
|
||||
|
||||
font = atlas->Fonts[1];
|
||||
ImGui::PushFont(font);
|
||||
ImGui::PushStyleColor(ImGuiCol_Text, type_color);
|
||||
|
||||
ImGui::TextUnformatted(item.path.filename().string().data());
|
||||
|
||||
pos.y += font->FontSize + 4.f;
|
||||
|
||||
ImGui::PopStyleColor();
|
||||
ImGui::PopFont();
|
||||
ImGui::PopID();
|
||||
}
|
||||
|
||||
|
||||
END_IMGUI_WIN();
|
||||
}
|
||||
|
||||
void navigation::on_event(system_event& e)
|
||||
{
|
||||
if (e.get_name() == try_engine::system_event::classificator::WINDOW_RESIZE())
|
||||
{
|
||||
height = try_engine::application::get()->get_window()->height() - 40.f;
|
||||
width = try_engine::application::get()->get_window()->width() / 3.f - padding_between_window;
|
||||
pos_x = try_engine::application::get()->get_window()->width() / 3.f + padding_between_window / 2.f;
|
||||
}
|
||||
}
|
||||
|
||||
void navigation::on_event(std::any e, std::any value)
|
||||
{
|
||||
}
|
||||
|
||||
void navigation::on_update(time t)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user