-
Notifications
You must be signed in to change notification settings - Fork 303
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b5b483d
commit 24cc50e
Showing
8 changed files
with
199 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
/** | ||
* @file lv_windows_interop.c | ||
* | ||
*/ | ||
|
||
/********************* | ||
* INCLUDES | ||
*********************/ | ||
|
||
#include "lv_windows_interop.h" | ||
#ifdef LV_USE_WINDOWS | ||
|
||
/********************* | ||
* DEFINES | ||
*********************/ | ||
|
||
/********************** | ||
* TYPEDEFS | ||
**********************/ | ||
|
||
/********************** | ||
* STATIC PROTOTYPES | ||
**********************/ | ||
|
||
/********************** | ||
* STATIC VARIABLES | ||
**********************/ | ||
|
||
/********************** | ||
* MACROS | ||
**********************/ | ||
|
||
/********************** | ||
* GLOBAL FUNCTIONS | ||
**********************/ | ||
|
||
EXTERN_C HWND lv_windows_get_display_window_handle( | ||
lv_display_t* display) | ||
{ | ||
return (HWND)lv_display_get_driver_data(display); | ||
} | ||
|
||
EXTERN_C 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
/** | ||
* @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 <windows.h> | ||
|
||
/********************* | ||
* 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*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters