add new system navigation
This commit is contained in:
@@ -12,6 +12,7 @@ namespace rrr::layers::gui
|
||||
BASE_WINDOW_FLAGS();
|
||||
|
||||
data = cnt->get(TYPE_WIN::NAVIGATION);
|
||||
selected_file = cnt->get_selected_file(TYPE_WIN::NAVIGATION);
|
||||
}
|
||||
|
||||
void navigation::on_detach()
|
||||
@@ -36,30 +37,32 @@ namespace rrr::layers::gui
|
||||
pos.y += 9.f; // небольшой отступ сверху
|
||||
ImGui::SetCursorPosY(pos.y);
|
||||
|
||||
int index = 0;
|
||||
for (auto& item : *data)
|
||||
{
|
||||
ImGui::PushID(item.id);
|
||||
|
||||
push_style(item);
|
||||
|
||||
if (cursor_position == index)
|
||||
if (selected_file.path == item.path)
|
||||
{
|
||||
font = try_engine::style::fonts::get_font(item.is_hidden ? font_type::SEMI_BOLD_ITALIC : font_type::SEMI_BOLD, 18);
|
||||
ImGui::PushFont(font);
|
||||
if (selected_file.is_hidden)
|
||||
TR_PUSH_FONT(SEMI_BOLD_ITALIC, 18);
|
||||
else
|
||||
TR_PUSH_FONT(SEMI_BOLD, 18);
|
||||
|
||||
ImGui::TextUnformatted(">");
|
||||
ImGui::SameLine(22.f);
|
||||
current_file = item;
|
||||
}
|
||||
else
|
||||
{
|
||||
ImGui::SetCursorPosX(pos.x);
|
||||
font = try_engine::style::fonts::get_font(item.is_hidden ? font_type::MEDIUM_ITALIC : font_type::MEDIUM, 18);
|
||||
ImGui::PushFont(font);
|
||||
if (item.is_hidden)
|
||||
TR_PUSH_FONT(MEDIUM_ITALIC, 18);
|
||||
else
|
||||
TR_PUSH_FONT(MEDIUM, 18);
|
||||
}
|
||||
|
||||
ImGui::TextUnformatted(get_file_content(item).data());
|
||||
++index;
|
||||
|
||||
pop_style(item);
|
||||
}
|
||||
@@ -81,14 +84,11 @@ namespace rrr::layers::gui
|
||||
|
||||
if (f.is_link)
|
||||
ImGui::PushStyleColor(ImGuiCol_Text, link_color);
|
||||
|
||||
if (f.is_hidden)
|
||||
font = try_engine::style::fonts::get_font(font_type::MEDIUM_ITALIC, 18);
|
||||
}
|
||||
|
||||
void navigation::pop_style(file& f)
|
||||
{
|
||||
ImGui::PopFont();
|
||||
TR_POP_FONT();
|
||||
ImGui::PopStyleColor();
|
||||
ImGui::PopID();
|
||||
|
||||
@@ -133,8 +133,8 @@ namespace rrr::layers::gui
|
||||
case types::event_type::DELETE_CURRENT_FILE:
|
||||
{
|
||||
freeze = false;
|
||||
cnt->delete_file(current_file);
|
||||
cursor_position = cnt->get_cursor_position(TYPE_WIN::NAVIGATION);
|
||||
cnt->delete_file(selected_file);
|
||||
selected_file = cnt->get_selected_file(TYPE_WIN::NAVIGATION);
|
||||
}
|
||||
break;
|
||||
case types::event_type::CREATE_FILE:
|
||||
@@ -142,7 +142,7 @@ namespace rrr::layers::gui
|
||||
freeze = false;
|
||||
auto filename = std::any_cast<std::string>(value);
|
||||
cnt->create_file(filename);
|
||||
cursor_position = cnt->get_cursor_position(TYPE_WIN::NAVIGATION);
|
||||
selected_file = cnt->get_selected_file(TYPE_WIN::NAVIGATION);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
@@ -200,7 +200,7 @@ namespace rrr::layers::gui
|
||||
// удаление
|
||||
if (shift && key.get_keycode() == try_engine::key::D)
|
||||
{
|
||||
em->execute(types::event_type::SHOW_DELETE_ONE_FILE_DIALOG, current_file);
|
||||
em->execute(types::event_type::SHOW_DELETE_ONE_FILE_DIALOG, selected_file);
|
||||
freeze = true;
|
||||
}
|
||||
|
||||
@@ -211,7 +211,7 @@ namespace rrr::layers::gui
|
||||
freeze = true;
|
||||
}
|
||||
|
||||
cursor_position = cnt->get_cursor_position(TYPE_WIN::NAVIGATION);
|
||||
selected_file = cnt->get_selected_file(TYPE_WIN::NAVIGATION);
|
||||
}
|
||||
|
||||
void navigation::released(system_event& e)
|
||||
|
||||
Reference in New Issue
Block a user