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

Scrollable Viewport #48

Open raphaelmenges opened 6 years ago

raphaelmenges commented 6 years ago

Hello @Dovyski,

I am showing dynamic / run-time dependent content in a window that underlying matrix is handled by cvui. It is possible to provide scrolling facilities in such window? E.g., cvui fills and handles a matrix as big required to paint all content and displays only a scrollable, fixed-size viewport onto the screen? I guess it might be required to take some care with mouse pointer coordinates in the viewport for interaction purposes, but it would make the usage much more flexibel for dynamic content.

Thanks for the library anyway, it is nice to be able to create an OpenCV GUI with such low overhead and be provided with a very good documentation!

Dovyski commented 6 years ago

Hi! Unfortunately, cvui does not provide scrolling facilities out of the box. What you could do is to continue using a big matrix to render cvui components, but then select a ROI out of it according to the clipping area.

Something like the following (very pseudo-code-ish):

cv::Mat bigMatrix;
cv::Mat visibleArea;
cv::Rect scrollROI(0, 0, bigMatrix.cols, 100);

cvui::text(bigMatrix, 10, 10, "Test");
bigMatrix(scrollROI).copyTo(visibleArea);

// then copy visibleArea to your UI matrix

You can then handle mouse and scrollbars using cvui::mouse(), but you need to work out the mechanics of scrolling, controlling where you are in the scrollable area, etc.

I've marked your issue as a feature request. It will be awesome to have scrollable content in cvui out of the box. I will work on it in the future.

Thanks for the library anyway, it is nice to be able to create an OpenCV GUI with such low overhead and be provided with a very good documentation!

Thank you very much! I'm glad to hear that.