diff --git a/src/rrr/layers/gui/browser/navigation/navigation.cpp b/src/rrr/layers/gui/browser/navigation/navigation.cpp index 4809622..c890287 100644 --- a/src/rrr/layers/gui/browser/navigation/navigation.cpp +++ b/src/rrr/layers/gui/browser/navigation/navigation.cpp @@ -333,6 +333,8 @@ namespace rrr::layers::gui em->execute(types::event_type::SHOW_HELP_DIALOG, nullptr); freeze = true; } + + detect_img(); } void navigation::released(system_event& e) @@ -433,4 +435,12 @@ namespace rrr::layers::gui buffers::get_instance().single_cut_buffer.clear(); selected_file = cnt->get_selected_file(TYPE_WIN::NAVIGATION); } + + void navigation::detect_img() + { + if (selected_file.path.extension() == ".jpg" || + selected_file.path.extension() == ".jpeg" || + selected_file.path.extension() == ".png") + em->execute(types::event_type::SHOW_IMG, selected_file.path); + } } diff --git a/src/rrr/layers/gui/browser/navigation/navigation.hpp b/src/rrr/layers/gui/browser/navigation/navigation.hpp index 8c84332..f095600 100644 --- a/src/rrr/layers/gui/browser/navigation/navigation.hpp +++ b/src/rrr/layers/gui/browser/navigation/navigation.hpp @@ -70,6 +70,7 @@ namespace rrr::layers::gui void set_scroll(); void paste_from_copy(); // вставка после копирования void paste_from_cut(); // вставки после вырезания + void detect_img(); }; } diff --git a/src/rrr/layers/gui/browser/preview/preview.cpp b/src/rrr/layers/gui/browser/preview/preview.cpp index 4a60849..202b8f8 100644 --- a/src/rrr/layers/gui/browser/preview/preview.cpp +++ b/src/rrr/layers/gui/browser/preview/preview.cpp @@ -29,7 +29,7 @@ namespace rrr::layers::gui BEGIN_IMGUI_WIN(); - auto pos = ImGui::GetCursorPos(); + ImVec2 pos = ImGui::GetCursorPos(); pos.x += 17.f; pos.y += 9.f; // небольшой отступ сверху ImGui::SetCursorPosY(pos.y); @@ -37,6 +37,22 @@ namespace rrr::layers::gui auto begin = data->begin() + delta; auto end = data->end(); + // потоки разные у on_event и этот + // по этому создание незя делать в switch + if (make_media) + { + make_media = false; + tx.make(); + frame = cv::imread(media_path); + cv::cvtColor(frame, frame, cv::COLOR_BGR2RGBA); + tx.bind(frame); + media_show = true; + hack::log()(width, height); + } + + if (media_show) + tx.draw(ImVec2(pos.x + 830.f, pos.y), ImVec2(width + 850.f, frame.rows / 1.6f)); + for (files::iterator it = begin; it != end; ++it) { auto item = *it; @@ -98,12 +114,18 @@ namespace rrr::layers::gui case types::event_type::NAVIGATION_DOWN: case types::event_type::NAVIGATION_LEFT: case types::event_type::NAVIGATION_RIGHT: + media_path.clear(); + media_show = false; selected_file = cnt->get_selected_file(TYPE_WIN::PREVIEW); cursor_position = 0; current_position = 0; delta = 0; set_scroll(); break; + case types::event_type::SHOW_IMG: + media_path = std::any_cast(value); + make_media = true; + break; default: break; } diff --git a/src/rrr/layers/gui/browser/preview/preview.hpp b/src/rrr/layers/gui/browser/preview/preview.hpp index c15a9f8..16661c7 100644 --- a/src/rrr/layers/gui/browser/preview/preview.hpp +++ b/src/rrr/layers/gui/browser/preview/preview.hpp @@ -41,6 +41,13 @@ namespace rrr::layers::gui int cursor_position = 0; // позиция курсора относительно высоты экрана int delta = 0; enum class MOVE_DIRECTION { UP, DOWN }; + + std::filesystem::path media_path; + try_engine::texture tx; + cv::Mat frame; + cv::VideoCapture cap; + bool media_show = false; + bool make_media = false; private: const ImVec4 dir_color = func::get_IMGUI_color(91.f, 128.f, 191.f); diff --git a/src/rrr/utils/types.hpp b/src/rrr/utils/types.hpp index a1f61d2..999f6f1 100644 --- a/src/rrr/utils/types.hpp +++ b/src/rrr/utils/types.hpp @@ -17,7 +17,8 @@ namespace rrr::types CREATE_FILE, SHOW_RENAME_FILE_DIALOG, RENAME_FILE, - SHOW_HELP_DIALOG + SHOW_HELP_DIALOG, + SHOW_IMG }; }