add get Scale and GetScaleSize func

This commit is contained in:
vcaesar 2018-07-09 23:29:27 +08:00
parent ec82b0fd15
commit 62b865dbef

View File

@ -188,13 +188,43 @@ func GetPixelColor(x, y int) string {
return gcolor
}
// GetScreenSize get screen size
// ScaleX get primary display horizontal DPI scale factor
func ScaleX() int {
return int(C.scalex())
}
// ScaleY get primary display vertical DPI scale factor
func ScaleY() int {
return int(C.scaley())
}
// GetScreenSize get the screen size
func GetScreenSize() (int, int) {
size := C.get_screen_size()
// fmt.Println("...", size, size.width)
return int(size.width), int(size.height)
}
// Scale get the screen scale
func Scale() int {
dip := map[int]int{
96: 100,
120: 125,
144: 150,
192: 200,
}
x := ScaleX()
return dip[x]
}
// GetScaleSize get the screen scale size
func GetScaleSize() (int, int) {
x, y := GetScreenSize()
s := Scale()
return x * s / 100, y * s / 100
}
// SetXDisplayName set XDisplay name
func SetXDisplayName(name string) string {
cname := C.CString(name)
@ -1293,16 +1323,6 @@ ____ __ ____ __ .__ __. _______ ______ ____ __ ____
*/
// ScaleX get primary display horizontal DPI scale factor
func ScaleX() int {
return int(C.scalex())
}
// ScaleY get primary display vertical DPI scale factor
func ScaleY() int {
return int(C.scaley())
}
// ShowAlert show a alert window
func ShowAlert(title, msg string, args ...string) int {
var (