diff --git a/LvglWindowsSimulator/LvglWindowsSimulator.cpp b/LvglWindowsSimulator/LvglWindowsSimulator.cpp index 5c05934..e18a638 100644 --- a/LvglWindowsSimulator/LvglWindowsSimulator.cpp +++ b/LvglWindowsSimulator/LvglWindowsSimulator.cpp @@ -26,7 +26,6 @@ #include "lvgl/demos/lv_demos.h" #include "lv_windows_context.h" -#include "lv_windows_interop.h" #include "lv_windows_input.h" #include "lv_windows_display.h" diff --git a/LvglWindowsSimulator/LvglWindowsSimulator.vcxproj b/LvglWindowsSimulator/LvglWindowsSimulator.vcxproj index e026b3d..e130871 100644 --- a/LvglWindowsSimulator/LvglWindowsSimulator.vcxproj +++ b/LvglWindowsSimulator/LvglWindowsSimulator.vcxproj @@ -339,7 +339,6 @@ - @@ -963,7 +962,6 @@ - diff --git a/LvglWindowsSimulator/LvglWindowsSimulator.vcxproj.filters b/LvglWindowsSimulator/LvglWindowsSimulator.vcxproj.filters index d772920..2f645cd 100644 --- a/LvglWindowsSimulator/LvglWindowsSimulator.vcxproj.filters +++ b/LvglWindowsSimulator/LvglWindowsSimulator.vcxproj.filters @@ -891,7 +891,6 @@ - @@ -2746,7 +2745,6 @@ - diff --git a/LvglWindowsSimulator/lv_windows_context.c b/LvglWindowsSimulator/lv_windows_context.c index 1601bcd..a4bc899 100644 --- a/LvglWindowsSimulator/lv_windows_context.c +++ b/LvglWindowsSimulator/lv_windows_context.c @@ -10,7 +10,7 @@ #include "lv_windows_context.h" #ifdef LV_USE_WINDOWS -#include "lv_windows_interop.h" +#include "lv_windows_display.h" /********************* * DEFINES diff --git a/LvglWindowsSimulator/lv_windows_display.c b/LvglWindowsSimulator/lv_windows_display.c index 151f3b6..54d2294 100644 --- a/LvglWindowsSimulator/lv_windows_display.c +++ b/LvglWindowsSimulator/lv_windows_display.c @@ -99,6 +99,31 @@ lv_display_t* lv_windows_create_display( return display; } +HWND lv_windows_get_display_window_handle(lv_display_t* display) +{ + return (HWND)lv_display_get_driver_data(display); +} + +int32_t lv_windows_zoom_to_logical(int32_t physical, int32_t zoom_level) +{ + return MulDiv(physical, LV_WINDOWS_ZOOM_BASE_LEVEL, zoom_level); +} + +int32_t lv_windows_zoom_to_physical(int32_t logical, int32_t zoom_level) +{ + return MulDiv(logical, zoom_level, LV_WINDOWS_ZOOM_BASE_LEVEL); +} + +int32_t lv_windows_dpi_to_logical(int32_t physical, int32_t dpi) +{ + return MulDiv(physical, USER_DEFAULT_SCREEN_DPI, dpi); +} + +int32_t lv_windows_dpi_to_physical(int32_t logical, int32_t dpi) +{ + return MulDiv(logical, dpi, USER_DEFAULT_SCREEN_DPI); +} + /********************** * STATIC FUNCTIONS **********************/ diff --git a/LvglWindowsSimulator/lv_windows_display.h b/LvglWindowsSimulator/lv_windows_display.h index 2b12a52..1a989be 100644 --- a/LvglWindowsSimulator/lv_windows_display.h +++ b/LvglWindowsSimulator/lv_windows_display.h @@ -22,10 +22,18 @@ extern "C" { #ifdef LV_USE_WINDOWS +#include + /********************* * DEFINES *********************/ +#define LV_WINDOWS_ZOOM_BASE_LEVEL 100 + +#ifndef USER_DEFAULT_SCREEN_DPI +#define USER_DEFAULT_SCREEN_DPI 96 +#endif + /********************** * TYPEDEFS **********************/ @@ -42,6 +50,61 @@ extern "C" { bool allow_dpi_override, bool simulator_mode); + /** + * @brief Get the window handle from specific LVGL display object. + * @param display The specific LVGL display object. + * @return The window handle from specific LVGL display object. + */ + HWND lv_windows_get_display_window_handle(lv_display_t* display); + + /** + * @brief Get logical pixel value from physical pixel value taken account + * with zoom level. + * @param physical The physical pixel value taken account with zoom level. + * @param zoom_level The zoom level value. Base value is 100 a.k.a 100%. + * @return The logical pixel value. + * @remark It uses the same calculation style as Windows OS implementation. + * It will be useful for integrate LVGL Windows backend to other + * Windows applications. + */ + int32_t lv_windows_zoom_to_logical(int32_t physical, int32_t zoom_level); + + /** + * @brief Get physical pixel value taken account with zoom level from + * logical pixel value. + * @param logical The logical pixel value. + * @param zoom_level The zoom level value. Base value is 100 a.k.a 100%. + * @return The physical pixel value taken account with zoom level. + * @remark It uses the same calculation style as Windows OS implementation. + * It will be useful for integrate LVGL Windows backend to other + * Windows applications. + */ + int32_t lv_windows_zoom_to_physical(int32_t logical, int32_t zoom_level); + + /** + * @brief Get logical pixel value from physical pixel value taken account + * with DPI scaling. + * @param physical The physical pixel value taken account with DPI scaling. + * @param dpi The DPI scaling value. Base value is USER_DEFAULT_SCREEN_DPI. + * @return The logical pixel value. + * @remark It uses the same calculation style as Windows OS implementation. + * It will be useful for integrate LVGL Windows backend to other + * Windows applications. + */ + int32_t lv_windows_dpi_to_logical(int32_t physical, int32_t dpi); + + /** + * @brief Get physical pixel value taken account with DPI scaling from + * logical pixel value. + * @param logical The logical pixel value. + * @param dpi The DPI scaling value. Base value is USER_DEFAULT_SCREEN_DPI. + * @return The physical pixel value taken account with DPI scaling. + * @remark It uses the same calculation style as Windows OS implementation. + * It will be useful for integrate LVGL Windows backend to other + * Windows applications. + */ + int32_t lv_windows_dpi_to_physical(int32_t logical, int32_t dpi); + /********************** * MACROS **********************/ diff --git a/LvglWindowsSimulator/lv_windows_input.c b/LvglWindowsSimulator/lv_windows_input.c index e89238f..4936cf9 100644 --- a/LvglWindowsSimulator/lv_windows_input.c +++ b/LvglWindowsSimulator/lv_windows_input.c @@ -11,7 +11,7 @@ #ifdef LV_USE_WINDOWS #include "lv_windows_context.h" -#include "lv_windows_interop.h" +#include "lv_windows_display.h" #include @@ -61,6 +61,11 @@ static void lv_windows_release_encoder_device_event_callback(lv_event_t* e); * GLOBAL FUNCTIONS **********************/ +HWND lv_windows_get_indev_window_handle(lv_indev_t* indev) +{ + return lv_windows_get_display_window_handle(lv_indev_get_display(indev)); +} + lv_indev_t* lv_windows_acquire_pointer_device(lv_display_t* display) { HWND window_handle = lv_windows_get_display_window_handle(display); diff --git a/LvglWindowsSimulator/lv_windows_input.h b/LvglWindowsSimulator/lv_windows_input.h index 8cd1a80..d573846 100644 --- a/LvglWindowsSimulator/lv_windows_input.h +++ b/LvglWindowsSimulator/lv_windows_input.h @@ -22,6 +22,8 @@ extern "C" { #ifdef LV_USE_WINDOWS +#include + /********************* * DEFINES *********************/ @@ -34,6 +36,13 @@ extern "C" { * GLOBAL PROTOTYPES **********************/ + /** + * @brief Get the window handle from specific LVGL input device object. + * @param indev The specific LVGL input device object. + * @return The window handle from specific LVGL input device object. + */ + HWND lv_windows_get_indev_window_handle(lv_indev_t* indev); + /** * @brief Open a LVGL pointer input device object for the specific LVGL * display object, or create it if the LVGL pointer input device diff --git a/LvglWindowsSimulator/lv_windows_interop.c b/LvglWindowsSimulator/lv_windows_interop.c deleted file mode 100644 index b89dbbe..0000000 --- a/LvglWindowsSimulator/lv_windows_interop.c +++ /dev/null @@ -1,71 +0,0 @@ -/** - * @file lv_windows_interop.c - * - */ - -/********************* - * INCLUDES - *********************/ - -#include "lv_windows_interop.h" -#ifdef LV_USE_WINDOWS - -/********************* - * DEFINES - *********************/ - -/********************** - * TYPEDEFS - **********************/ - -/********************** - * STATIC PROTOTYPES - **********************/ - -/********************** - * STATIC VARIABLES - **********************/ - -/********************** - * MACROS - **********************/ - -/********************** - * GLOBAL FUNCTIONS - **********************/ - -HWND lv_windows_get_display_window_handle(lv_display_t* display) -{ - return (HWND)lv_display_get_driver_data(display); -} - -HWND lv_windows_get_indev_window_handle(lv_indev_t* indev) -{ - return lv_windows_get_display_window_handle(lv_indev_get_display(indev)); -} - -int32_t lv_windows_zoom_to_logical(int32_t physical, int32_t zoom_level) -{ - return MulDiv(physical, LV_WINDOWS_ZOOM_BASE_LEVEL, zoom_level); -} - -int32_t lv_windows_zoom_to_physical(int32_t logical, int32_t zoom_level) -{ - return MulDiv(logical, zoom_level, LV_WINDOWS_ZOOM_BASE_LEVEL); -} - -int32_t lv_windows_dpi_to_logical(int32_t physical, int32_t dpi) -{ - return MulDiv(physical, USER_DEFAULT_SCREEN_DPI, dpi); -} - -int32_t lv_windows_dpi_to_physical(int32_t logical, int32_t dpi) -{ - return MulDiv(logical, dpi, USER_DEFAULT_SCREEN_DPI); -} - -/********************** - * STATIC FUNCTIONS - **********************/ - -#endif // LV_USE_WINDOWS diff --git a/LvglWindowsSimulator/lv_windows_interop.h b/LvglWindowsSimulator/lv_windows_interop.h deleted file mode 100644 index bf39dff..0000000 --- a/LvglWindowsSimulator/lv_windows_interop.h +++ /dev/null @@ -1,117 +0,0 @@ -/** - * @file lv_windows_interop.h - * - */ - -#ifndef LV_WINDOWS_INTEROP_H -#define LV_WINDOWS_INTEROP_H - -#ifdef __cplusplus -extern "C" { -#endif - -/********************* - * INCLUDES - *********************/ - -#include "lvgl.h" -#define LV_USE_WINDOWS - -//#include "../../display/lv_display.h" -//#include "../../indev/lv_indev.h" - -#ifdef LV_USE_WINDOWS - -#include - -/********************* - * DEFINES - *********************/ - -#define LV_WINDOWS_ZOOM_BASE_LEVEL 100 - -#ifndef USER_DEFAULT_SCREEN_DPI -#define USER_DEFAULT_SCREEN_DPI 96 -#endif - -/********************** - * TYPEDEFS - **********************/ - -/********************** - * GLOBAL PROTOTYPES - **********************/ - - /** - * @brief Get the window handle from specific LVGL display object. - * @param display The specific LVGL display object. - * @return The window handle from specific LVGL display object. - */ - HWND lv_windows_get_display_window_handle(lv_display_t* display); - - /** - * @brief Get the window handle from specific LVGL input device object. - * @param indev The specific LVGL input device object. - * @return The window handle from specific LVGL input device object. - */ - HWND lv_windows_get_indev_window_handle(lv_indev_t* indev); - - /** - * @brief Get logical pixel value from physical pixel value taken account - * with zoom level. - * @param physical The physical pixel value taken account with zoom level. - * @param zoom_level The zoom level value. Base value is 100 a.k.a 100%. - * @return The logical pixel value. - * @remark It uses the same calculation style as Windows OS implementation. - * It will be useful for integrate LVGL Windows backend to other - * Windows applications. - */ - int32_t lv_windows_zoom_to_logical(int32_t physical, int32_t zoom_level); - - /** - * @brief Get physical pixel value taken account with zoom level from - * logical pixel value. - * @param logical The logical pixel value. - * @param zoom_level The zoom level value. Base value is 100 a.k.a 100%. - * @return The physical pixel value taken account with zoom level. - * @remark It uses the same calculation style as Windows OS implementation. - * It will be useful for integrate LVGL Windows backend to other - * Windows applications. - */ - int32_t lv_windows_zoom_to_physical(int32_t logical, int32_t zoom_level); - - /** - * @brief Get logical pixel value from physical pixel value taken account - * with DPI scaling. - * @param physical The physical pixel value taken account with DPI scaling. - * @param dpi The DPI scaling value. Base value is USER_DEFAULT_SCREEN_DPI. - * @return The logical pixel value. - * @remark It uses the same calculation style as Windows OS implementation. - * It will be useful for integrate LVGL Windows backend to other - * Windows applications. - */ - int32_t lv_windows_dpi_to_logical(int32_t physical, int32_t dpi); - - /** - * @brief Get physical pixel value taken account with DPI scaling from - * logical pixel value. - * @param logical The logical pixel value. - * @param dpi The DPI scaling value. Base value is USER_DEFAULT_SCREEN_DPI. - * @return The physical pixel value taken account with DPI scaling. - * @remark It uses the same calculation style as Windows OS implementation. - * It will be useful for integrate LVGL Windows backend to other - * Windows applications. - */ - int32_t lv_windows_dpi_to_physical(int32_t logical, int32_t dpi); - -/********************** - * MACROS - **********************/ - -#endif // LV_USE_WINDOWS - -#ifdef __cplusplus -} /*extern "C"*/ -#endif - -#endif /*LV_WINDOWS_INTEROP_H*/