Dovyski / cvui

A (very) simple UI lib built on top of OpenCV drawing primitives
https://dovyski.github.io/cvui/
MIT License
832 stars 213 forks source link

Moving more trackbars on single mouse down #84

Open freetomik opened 5 years ago

freetomik commented 5 years ago

I have more trackbars below each other. When I am moving first one, and go with mouse cursor over next ones, they are being moved instead of first one. It is quite annoying. Could this be fixed to moving only firstly selected trackbar, please?

Dovyski commented 5 years ago

Thanks for your report! Could you please provide a snippet of your code so I can better understand the problem? Are you using a single window for your application or multiple windows, for instance?

freetomik commented 5 years ago

I am using a single window. I just have several trackbars below each other:

cvui::trackbar(...);
cvui::trackbar(...);
cvui::trackbar(...);
cvui::trackbar(...);

cvui_trackbars When I hold most top trackbar and move mouse into trails of trackbars below, they are moved instead of the top one, which I am holding. [EDIT] Note: Putting trackbars into rows does not help.

Dovyski commented 5 years ago

Could you provide a bit more code regarding the cvui::trackbar(...); call, please? What is in the (...) and what variables are you using?

freetomik commented 5 years ago

Sure, here is complete minimal working example:

#include <opencv2/opencv.hpp>

#define CVUI_IMPLEMENTATION
#include "cvui.h"

int main(int argc, char** argv)
{
    double a = 50.0;
    double b = 25.0;

    const double min = 0.0;
    const double max = 100.0;

    cv::namedWindow("Window", cv::WINDOW_AUTOSIZE);
    cvui::init("Window");

    cv::Mat frame = cv::Mat::zeros(120, 500, CV_8U);

    while (true)
    {
        cvui::window(frame, 0, 0, frame.cols, frame.rows, "Settings");

        cvui::trackbar(frame, 20, 20, frame.cols - 50, &a, min, max);
        cvui::trackbar(frame, 20, 60, frame.cols - 50, &b, min, max);

        cvui::imshow("Window", frame);

        if (cv::waitKey(30) == 27) break;
    }

    return 0;
}
freetomik commented 5 years ago

Behaviour looks like this: cvui_trackbars This is on single mouse down. When user wants to change only one parameter at time, back and forth, it is annoying, when other parameters are also changed, if he/she misses the exact horizontal trail of the trackbar. [EDIT]: CVUI is otherwise great idea and very useful - thanks for making it! But this one thing I found uncomfortable.

Dovyski commented 5 years ago

Thank you for your information. I'll work on this bug as soon as I have some free time.