add base navigation left and right
This commit is contained in:
@@ -34,8 +34,12 @@ namespace rrr::layers::gui
|
||||
pos.y += 9.f; // небольшой отступ сверху
|
||||
ImGui::SetCursorPosY(pos.y);
|
||||
|
||||
for (auto& item : *data)
|
||||
auto begin = data->begin() + delta;
|
||||
auto end = data->end();
|
||||
|
||||
for (files::iterator it = begin; it != end; ++it)
|
||||
{
|
||||
auto item = *it;
|
||||
ImGui::PushID(item.id);
|
||||
|
||||
if (item.type == file_type::DIR)
|
||||
@@ -48,6 +52,7 @@ namespace rrr::layers::gui
|
||||
TR_PUSH_FONT(SEMI_BOLD, 18);
|
||||
ImGui::TextUnformatted(">");
|
||||
ImGui::SameLine(22.f);
|
||||
current_position = it - data->begin();
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -86,6 +91,7 @@ namespace rrr::layers::gui
|
||||
case types::event_type::NAVIGATION_LEFT:
|
||||
case types::event_type::NAVIGATION_RIGHT:
|
||||
selected_file = cnt->get_selected_file(TYPE_WIN::HISTORY);
|
||||
set_scroll();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@@ -96,5 +102,80 @@ namespace rrr::layers::gui
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void history::set_delta(MOVE_DIRECTION mvd)
|
||||
{
|
||||
auto row_size = 26.3f; // высота вы пикселях одной строки списка
|
||||
int h = height / row_size; // высота в строках списка всего столбца экрана
|
||||
auto big_content = height < data->size() * row_size;
|
||||
|
||||
int size = data->size();
|
||||
|
||||
if (big_content)
|
||||
{
|
||||
if (mvd == MOVE_DIRECTION::DOWN)
|
||||
{
|
||||
++cursor_position;
|
||||
|
||||
// на самом деле получаем его выше, но делаем такой трюк
|
||||
// т.к. происходит задержка на один ход нажатия клавиши
|
||||
++current_position;
|
||||
if (current_position >= size) current_position = size - 1;
|
||||
|
||||
bool is_end = size - current_position <= 10;
|
||||
if (cursor_position >= h - 10 && !is_end)
|
||||
{
|
||||
++delta;
|
||||
cursor_position = h - 10;
|
||||
}
|
||||
|
||||
if (cursor_position >= h) cursor_position = h;
|
||||
}
|
||||
|
||||
if (mvd == MOVE_DIRECTION::UP)
|
||||
{
|
||||
--cursor_position;
|
||||
--current_position;
|
||||
|
||||
if (cursor_position <= 10)
|
||||
--delta;
|
||||
|
||||
if (cursor_position < 10 && current_position > 12)
|
||||
cursor_position = 10;
|
||||
|
||||
if (delta < 0)
|
||||
{
|
||||
delta = 0;
|
||||
cursor_position = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void history::set_scroll()
|
||||
{
|
||||
delta = 0;
|
||||
current_position = 0;
|
||||
cursor_position = 0;
|
||||
|
||||
auto row_size = 26.3f; // высота вы пикселях одной строки списка
|
||||
auto big_content = height < data->size() * row_size;
|
||||
|
||||
if (big_content)
|
||||
{
|
||||
for (const auto& f : *data)
|
||||
{
|
||||
if (f.path != selected_file.path)
|
||||
{
|
||||
set_delta(MOVE_DIRECTION::DOWN);
|
||||
}
|
||||
else
|
||||
{
|
||||
set_delta(MOVE_DIRECTION::DOWN);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user