highgui: win32ui plugin
This commit is contained in:
parent
53eca2ff5b
commit
ef2b400c61
@ -2,15 +2,6 @@
|
|||||||
# Detect 3rd-party GUI libraries
|
# Detect 3rd-party GUI libraries
|
||||||
# ----------------------------------------------------------------------------
|
# ----------------------------------------------------------------------------
|
||||||
|
|
||||||
#--- Win32 UI ---
|
|
||||||
ocv_clear_vars(HAVE_WIN32UI)
|
|
||||||
if(WITH_WIN32UI)
|
|
||||||
try_compile(HAVE_WIN32UI
|
|
||||||
"${OpenCV_BINARY_DIR}"
|
|
||||||
"${OpenCV_SOURCE_DIR}/cmake/checks/win32uitest.cpp"
|
|
||||||
CMAKE_FLAGS "-DLINK_LIBRARIES:STRING=user32;gdi32")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# --- QT4/5 ---
|
# --- QT4/5 ---
|
||||||
ocv_clear_vars(HAVE_QT HAVE_QT5)
|
ocv_clear_vars(HAVE_QT HAVE_QT5)
|
||||||
if(WITH_QT)
|
if(WITH_QT)
|
||||||
|
|||||||
@ -121,9 +121,6 @@
|
|||||||
/* TIFF codec */
|
/* TIFF codec */
|
||||||
#cmakedefine HAVE_TIFF
|
#cmakedefine HAVE_TIFF
|
||||||
|
|
||||||
/* Win32 UI */
|
|
||||||
#cmakedefine HAVE_WIN32UI
|
|
||||||
|
|
||||||
/* Define if your processor stores words with the most significant byte
|
/* Define if your processor stores words with the most significant byte
|
||||||
first (like Motorola and SPARC, unlike Intel and VAX). */
|
first (like Motorola and SPARC, unlike Intel and VAX). */
|
||||||
#cmakedefine WORDS_BIGENDIAN
|
#cmakedefine WORDS_BIGENDIAN
|
||||||
|
|||||||
@ -131,12 +131,6 @@ elseif(WINRT)
|
|||||||
message(STATUS " ${name}: Removing 'comctl32.lib, gdi32.lib, ole32.lib, setupapi.lib'")
|
message(STATUS " ${name}: Removing 'comctl32.lib, gdi32.lib, ole32.lib, setupapi.lib'")
|
||||||
message(STATUS " ${name}: Leaving '${HIGHGUI_LIBRARIES}'")
|
message(STATUS " ${name}: Leaving '${HIGHGUI_LIBRARIES}'")
|
||||||
endif()
|
endif()
|
||||||
elseif(HAVE_WIN32UI)
|
|
||||||
set(OPENCV_HIGHGUI_BUILTIN_BACKEND "WIN32UI")
|
|
||||||
list(APPEND highgui_srcs ${CMAKE_CURRENT_LIST_DIR}/src/window_w32.cpp)
|
|
||||||
if(OpenCV_ARCH STREQUAL "ARM64")
|
|
||||||
list(APPEND HIGHGUI_LIBRARIES "comdlg32" "advapi32")
|
|
||||||
endif()
|
|
||||||
elseif(HAVE_COCOA)
|
elseif(HAVE_COCOA)
|
||||||
set(OPENCV_HIGHGUI_BUILTIN_BACKEND "COCOA")
|
set(OPENCV_HIGHGUI_BUILTIN_BACKEND "COCOA")
|
||||||
add_definitions(-DHAVE_COCOA)
|
add_definitions(-DHAVE_COCOA)
|
||||||
@ -144,6 +138,16 @@ elseif(HAVE_COCOA)
|
|||||||
list(APPEND HIGHGUI_LIBRARIES "-framework Cocoa")
|
list(APPEND HIGHGUI_LIBRARIES "-framework Cocoa")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if(TARGET ocv.3rdparty.win32ui)
|
||||||
|
if("win32ui" IN_LIST HIGHGUI_PLUGIN_LIST OR HIGHGUI_PLUGIN_LIST STREQUAL "all")
|
||||||
|
ocv_create_builtin_highgui_plugin(opencv_highgui_win32 ocv.3rdparty.win32ui "window_w32.cpp")
|
||||||
|
else()
|
||||||
|
set(OPENCV_HIGHGUI_BUILTIN_BACKEND "WIN32UI")
|
||||||
|
list(APPEND highgui_srcs ${CMAKE_CURRENT_LIST_DIR}/src/window_w32.cpp)
|
||||||
|
list(APPEND tgts ocv.3rdparty.win32ui)
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
if(TARGET ocv.3rdparty.gtk3 OR TARGET ocv.3rdparty.gtk2)
|
if(TARGET ocv.3rdparty.gtk3 OR TARGET ocv.3rdparty.gtk2)
|
||||||
if(TARGET ocv.3rdparty.gtk3 AND NOT WITH_GTK_2_X)
|
if(TARGET ocv.3rdparty.gtk3 AND NOT WITH_GTK_2_X)
|
||||||
set(__gtk_dependency "ocv.3rdparty.gtk3")
|
set(__gtk_dependency "ocv.3rdparty.gtk3")
|
||||||
|
|||||||
17
modules/highgui/cmake/detect_win32ui.cmake
Normal file
17
modules/highgui/cmake/detect_win32ui.cmake
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
#--- Win32 UI ---
|
||||||
|
ocv_clear_vars(HAVE_WIN32UI)
|
||||||
|
if(WITH_WIN32UI)
|
||||||
|
try_compile(HAVE_WIN32UI
|
||||||
|
"${CMAKE_CURRENT_BINARY_DIR}"
|
||||||
|
"${OpenCV_SOURCE_DIR}/cmake/checks/win32uitest.cpp"
|
||||||
|
CMAKE_FLAGS "-DLINK_LIBRARIES:STRING=user32;gdi32")
|
||||||
|
if(HAVE_WIN32UI)
|
||||||
|
set(__libs "user32" "gdi32")
|
||||||
|
if(OpenCV_ARCH STREQUAL "ARM64")
|
||||||
|
list(APPEND __libs "comdlg32" "advapi32")
|
||||||
|
endif()
|
||||||
|
ocv_add_external_target(win32ui "" "${__libs}" "HAVE_WIN32UI")
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
set(HAVE_WIN32UI "${HAVE_WIN32UI}" PARENT_SCOPE) # informational
|
||||||
@ -43,8 +43,7 @@ else()
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
add_backend("gtk" WITH_GTK)
|
add_backend("gtk" WITH_GTK)
|
||||||
|
add_backend("win32ui" WITH_WIN32UI)
|
||||||
# TODO win32
|
|
||||||
# TODO cocoa
|
# TODO cocoa
|
||||||
# TODO qt
|
# TODO qt
|
||||||
# TODO opengl
|
# TODO opengl
|
||||||
|
|||||||
@ -114,6 +114,10 @@ bool setUIBackend(const std::string& backendName);
|
|||||||
|
|
||||||
#ifndef BUILD_PLUGIN
|
#ifndef BUILD_PLUGIN
|
||||||
|
|
||||||
|
#ifdef HAVE_WIN32UI
|
||||||
|
std::shared_ptr<UIBackend> createUIBackendWin32UI();
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_GTK
|
#ifdef HAVE_GTK
|
||||||
std::shared_ptr<UIBackend> createUIBackendGTK();
|
std::shared_ptr<UIBackend> createUIBackendGTK();
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@ -67,7 +67,6 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <assert.h>
|
|
||||||
|
|
||||||
#if defined _WIN32 || defined WINCE
|
#if defined _WIN32 || defined WINCE
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
@ -127,6 +126,13 @@ void cvSetPropTopmost_COCOA(const char* name, const bool topmost);
|
|||||||
double cvGetPropVsync_W32(const char* name);
|
double cvGetPropVsync_W32(const char* name);
|
||||||
void cvSetPropVsync_W32(const char* name, const bool enabled);
|
void cvSetPropVsync_W32(const char* name, const bool enabled);
|
||||||
|
|
||||||
|
void setWindowTitle_W32(const cv::String& name, const cv::String& title);
|
||||||
|
void setWindowTitle_GTK(const cv::String& name, const cv::String& title);
|
||||||
|
void setWindowTitle_QT(const cv::String& name, const cv::String& title);
|
||||||
|
void setWindowTitle_COCOA(const cv::String& name, const cv::String& title);
|
||||||
|
|
||||||
|
int pollKey_W32();
|
||||||
|
|
||||||
//for QT
|
//for QT
|
||||||
#if defined (HAVE_QT)
|
#if defined (HAVE_QT)
|
||||||
CvRect cvGetWindowRect_QT(const char* name);
|
CvRect cvGetWindowRect_QT(const char* name);
|
||||||
|
|||||||
@ -50,6 +50,14 @@ std::vector<BackendInfo>& getBuiltinBackendsInfo()
|
|||||||
#elif defined(ENABLE_PLUGINS)
|
#elif defined(ENABLE_PLUGINS)
|
||||||
DECLARE_DYNAMIC_BACKEND("QT")
|
DECLARE_DYNAMIC_BACKEND("QT")
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
#ifdef HAVE_WIN32UI
|
||||||
|
DECLARE_STATIC_BACKEND("WIN32", createUIBackendWin32UI)
|
||||||
|
#elif defined(ENABLE_PLUGINS)
|
||||||
|
DECLARE_DYNAMIC_BACKEND("WIN32")
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
return g_backends;
|
return g_backends;
|
||||||
|
|||||||
@ -586,6 +586,46 @@ void cv::moveWindow( const String& winname, int x, int y )
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void cv::setWindowTitle(const String& winname, const String& title)
|
||||||
|
{
|
||||||
|
CV_TRACE_FUNCTION();
|
||||||
|
|
||||||
|
{
|
||||||
|
cv::AutoLock lock(cv::getWindowMutex());
|
||||||
|
auto window = findWindow_(winname);
|
||||||
|
if (window)
|
||||||
|
{
|
||||||
|
return window->setTitle(title);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#if defined(OPENCV_HIGHGUI_WITHOUT_BUILTIN_BACKEND) && defined(ENABLE_PLUGINS)
|
||||||
|
auto backend = getCurrentUIBackend();
|
||||||
|
if (backend)
|
||||||
|
{
|
||||||
|
CV_LOG_WARNING(NULL, "Can't find window with name: '" << winname << "'. Do nothing");
|
||||||
|
CV_NOT_FOUND_DEPRECATION;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
CV_LOG_WARNING(NULL, "No UI backends available. Use OPENCV_LOG_LEVEL=DEBUG for investigation");
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
#elif defined(HAVE_WIN32UI)
|
||||||
|
return setWindowTitle_W32(winname, title);
|
||||||
|
#elif defined (HAVE_GTK)
|
||||||
|
return setWindowTitle_GTK(winname, title);
|
||||||
|
#elif defined (HAVE_QT)
|
||||||
|
return setWindowTitle_QT(winname, title);
|
||||||
|
#elif defined (HAVE_COCOA)
|
||||||
|
return setWindowTitle_COCOA(winname, title);
|
||||||
|
#else
|
||||||
|
CV_Error(Error::StsNotImplemented, "The function is not implemented. "
|
||||||
|
"Rebuild the library with Windows, GTK+ 2.x or Cocoa support. "
|
||||||
|
"If you are on Ubuntu or Debian, install libgtk2.0-dev and pkg-config, then re-run cmake or configure script");
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
void cv::setWindowProperty(const String& winname, int prop_id, double prop_value)
|
void cv::setWindowProperty(const String& winname, int prop_id, double prop_value)
|
||||||
{
|
{
|
||||||
CV_TRACE_FUNCTION();
|
CV_TRACE_FUNCTION();
|
||||||
@ -630,9 +670,9 @@ int cv::waitKey(int delay)
|
|||||||
return (code != -1) ? (code & 0xff) : -1;
|
return (code != -1) ? (code & 0xff) : -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(HAVE_QT) || (defined (WINRT) && !defined (WINRT_8_0)) || \
|
/*
|
||||||
!defined(HAVE_WIN32UI) && (defined(HAVE_GTK) || defined(HAVE_COCOA))
|
* process until queue is empty but don't wait.
|
||||||
// pollKey() fallback implementation
|
*/
|
||||||
int cv::pollKey()
|
int cv::pollKey()
|
||||||
{
|
{
|
||||||
CV_TRACE_FUNCTION();
|
CV_TRACE_FUNCTION();
|
||||||
@ -646,12 +686,13 @@ int cv::pollKey()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(HAVE_WIN32UI)
|
||||||
|
return pollKey_W32();
|
||||||
|
#else
|
||||||
// fallback. please implement a proper polling function
|
// fallback. please implement a proper polling function
|
||||||
return cvWaitKey(1);
|
return cvWaitKey(1);
|
||||||
}
|
|
||||||
#elif defined(HAVE_WIN32UI)
|
|
||||||
// pollKey() implemented in window_w32.cpp
|
|
||||||
#endif
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
int cv::createTrackbar(const String& trackbarName, const String& winName,
|
int cv::createTrackbar(const String& trackbarName, const String& winName,
|
||||||
int* value, int count, TrackbarCallback callback,
|
int* value, int count, TrackbarCallback callback,
|
||||||
@ -1203,13 +1244,6 @@ int cv::createButton(const String&, ButtonCallback, void*, int , bool )
|
|||||||
// version with a more capable one without a need to recompile dependent
|
// version with a more capable one without a need to recompile dependent
|
||||||
// applications or libraries.
|
// applications or libraries.
|
||||||
|
|
||||||
void cv::setWindowTitle(const String&, const String&)
|
|
||||||
{
|
|
||||||
CV_Error(Error::StsNotImplemented, "The function is not implemented. "
|
|
||||||
"Rebuild the library with Windows, GTK+ 2.x or Cocoa support. "
|
|
||||||
"If you are on Ubuntu or Debian, install libgtk2.0-dev and pkg-config, then re-run cmake or configure script");
|
|
||||||
}
|
|
||||||
|
|
||||||
#define CV_NO_GUI_ERROR(funcname) \
|
#define CV_NO_GUI_ERROR(funcname) \
|
||||||
cv::error(cv::Error::StsError, \
|
cv::error(cv::Error::StsError, \
|
||||||
"The function is not implemented. " \
|
"The function is not implemented. " \
|
||||||
@ -1360,11 +1394,6 @@ CV_IMPL int cvCreateButton(const char*, void (*)(int, void*), void*, int, int)
|
|||||||
CV_NO_GUI_ERROR("cvCreateButton");
|
CV_NO_GUI_ERROR("cvCreateButton");
|
||||||
}
|
}
|
||||||
|
|
||||||
int cv::pollKey()
|
|
||||||
{
|
|
||||||
CV_NO_GUI_ERROR("cv::pollKey()");
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* End of file. */
|
/* End of file. */
|
||||||
|
|||||||
@ -63,6 +63,7 @@
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
using namespace cv;
|
||||||
|
|
||||||
//Static and global first
|
//Static and global first
|
||||||
static GuiReceiver *guiMainThread = NULL;
|
static GuiReceiver *guiMainThread = NULL;
|
||||||
@ -197,7 +198,7 @@ void cvSetPropWindow_QT(const char* name,double prop_value)
|
|||||||
Q_ARG(double, prop_value));
|
Q_ARG(double, prop_value));
|
||||||
}
|
}
|
||||||
|
|
||||||
void cv::setWindowTitle(const String& winname, const String& title)
|
void setWindowTitle_QT(const String& winname, const String& title)
|
||||||
{
|
{
|
||||||
if (!guiMainThread)
|
if (!guiMainThread)
|
||||||
CV_Error(Error::StsNullPtr, "NULL guiReceiver (please create a window)");
|
CV_Error(Error::StsNullPtr, "NULL guiReceiver (please create a window)");
|
||||||
|
|||||||
@ -795,18 +795,18 @@ void cvSetPropTopmost_COCOA( const char* name, const bool topmost )
|
|||||||
__END__;
|
__END__;
|
||||||
}
|
}
|
||||||
|
|
||||||
void cv::setWindowTitle(const String& winname, const String& title)
|
void setWindowTitle_COCOA(const cv::String& winname, const cv::String& title)
|
||||||
{
|
{
|
||||||
CVWindow *window = cvGetWindow(winname.c_str());
|
CVWindow *window = cvGetWindow(winname.c_str());
|
||||||
|
|
||||||
if (window == NULL)
|
if (window == NULL)
|
||||||
{
|
{
|
||||||
namedWindow(winname);
|
cv::namedWindow(winname);
|
||||||
window = cvGetWindow(winname.c_str());
|
window = cvGetWindow(winname.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (window == NULL)
|
if (window == NULL)
|
||||||
CV_Error(Error::StsNullPtr, "NULL window");
|
CV_Error(cv::Error::StsNullPtr, "NULL window");
|
||||||
|
|
||||||
NSAutoreleasePool* localpool = [[NSAutoreleasePool alloc] init];
|
NSAutoreleasePool* localpool = [[NSAutoreleasePool alloc] init];
|
||||||
|
|
||||||
|
|||||||
@ -364,7 +364,7 @@ static void cvImageWidget_set_size(GtkWidget * widget, int max_width, int max_he
|
|||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
assert( image_widget->scaled_image );
|
CV_Assert(image_widget->scaled_image);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -849,7 +849,7 @@ static bool setModeWindow_(const std::shared_ptr<CvWindow>& window, int mode)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void cv::setWindowTitle(const String& winname, const String& title)
|
void setWindowTitle_GTK(const String& winname, const String& title)
|
||||||
{
|
{
|
||||||
CV_LOCK_MUTEX();
|
CV_LOCK_MUTEX();
|
||||||
|
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user