• Я зарабатываю 100 000 RUB / месяц на этом сайте!

    А знаешь как? Я всего-лишь публикую (создаю темы), а админ мне платит. Трачу деньги на мороженое, робуксы и сервера в Minecraft. А ещё на паль из Китая. 

    Хочешь так же? Пиши и узнавай условия: https://t.me/alex_redact
    Реклама: https://t.me/yougame_official

Исходник Перемещение елементов с помощью мышки

Тьомчик
Участник
Участник
Статус
Оффлайн
Регистрация
30 Июн 2020
Сообщения
799
Реакции
159
C++:
Expand Collapse Copy
ImVec2 PortableSquare(ImVec2 position, const ImVec2& size) {
         ImVec2 rect_min = position;
         ImVec2 rect_max = position + size;

         bool is_hovered = ImGui::GetMousePos().x >= rect_min.x &&
             ImGui::GetMousePos().y >= rect_min.y &&
             ImGui::GetMousePos().x <= rect_max.x &&
             ImGui::GetMousePos().y <= rect_max.y;

         /*
         * also you can create a window and use it but which diffrence with default function?
         * bool is_hovered = ImGui::IsItemHovered();
         * bool is_hovered = ImGui::IsMouseHoveringRect(rect_min, rect_max);
         */

         if (ImGui::IsMouseDragging(ImGuiMouseButton_Left) && is_hovered) {
             position += ImGui::GetMouseDragDelta(ImGuiMouseButton_Left);
             ImGui::ResetMouseDragDelta(ImGuiMouseButton_Left);
         }

         position = ImClamp(position, ImVec2(0.0f, 0.0f), ImVec2(ImGui::GetScreenSize().x - size.x, ImGui::GetScreenSize().y - size.y));

         return position;
     }
 
а почему не в раздел по c/c++?
 
Назад
Сверху Снизу