add style and base navigation

This commit is contained in:
chatlanin
2023-03-12 12:50:05 +03:00
parent 3d6f90f0d9
commit 44ed461df9
12 changed files with 408 additions and 51 deletions

View File

@@ -5,6 +5,9 @@ namespace rrr::layers::gui
void history::on_attach()
{
BASE_WINDOW_FLAGS();
data = cnt->get(TYPE_WIN::HISTORY);
cursor_position = cnt->get_cursor_position(TYPE_WIN::HISTORY);
}
void history::on_detach()
@@ -17,8 +20,47 @@ namespace rrr::layers::gui
ImGui::SetNextWindowPos(ImVec2(pos_x, pos_y));
ImGui::SetNextWindowSize(ImVec2(width, height));
ImGuiStyle& st = ImGui::GetStyle();
st.Colors[ImGuiCol_WindowBg] = ImVec4(0.13f, 0.14f, 0.18f, 1.00f);
BEGIN_IMGUI_WIN();
auto pos = ImGui::GetCursorPos();
pos.x += 17.f;
pos.y += 9.f; // небольшой отступ сверху
ImGui::SetCursorPosY(pos.y);
int index = 0;
for (auto& item : *data)
{
ImGui::PushID(item.id);
if (item.type == file_type::DIR)
ImGui::PushStyleColor(ImGuiCol_Text, dir_color);
else
ImGui::PushStyleColor(ImGuiCol_Text, file_color);
if (cursor_position == index)
{
font = try_engine::style::fonts::get_font(font_type::SEMI_BOLD, 18);
ImGui::PushFont(font);
ImGui::TextUnformatted(">");
ImGui::SameLine(22.f);
}
else
{
ImGui::SetCursorPosX(pos.x);
font = try_engine::style::fonts::get_font(font_type::MEDIUM, 18);
ImGui::PushFont(font);
}
ImGui::TextUnformatted(item.path.filename().string().data());
++index;
ImGui::PopFont();
ImGui::PopStyleColor();
ImGui::PopID();
}
END_IMGUI_WIN();
}
@@ -26,10 +68,13 @@ namespace rrr::layers::gui
void history::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;
}
resize();
}
void history::resize()
{
height = try_engine::application::get()->get_window()->height();
width = try_engine::application::get()->get_window()->width() / 3.f;
}
void history::on_event(std::any e, std::any value)