From 4f100f92d859848f44c972c08e7fbf37c04e8d3e Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Sun, 29 May 2016 13:40:00 -0300 Subject: DPI Detection support Windows only for now. Many builds may break (older visual studio, mingw32) --- core/bind/core_bind.cpp | 6 ++++++ core/bind/core_bind.h | 1 + core/os/os.h | 1 + 3 files changed, 8 insertions(+) (limited to 'core') diff --git a/core/bind/core_bind.cpp b/core/bind/core_bind.cpp index e8703dccca..addc26525e 100644 --- a/core/bind/core_bind.cpp +++ b/core/bind/core_bind.cpp @@ -226,6 +226,11 @@ Size2 _OS::get_screen_size(int p_screen) const { return OS::get_singleton()->get_screen_size(p_screen); } +int _OS::get_screen_dpi(int p_screen) const { + + return OS::get_singleton()->get_screen_dpi(p_screen); +} + Point2 _OS::get_window_position() const { return OS::get_singleton()->get_window_position(); } @@ -984,6 +989,7 @@ void _OS::_bind_methods() { ObjectTypeDB::bind_method(_MD("set_current_screen","screen"),&_OS::set_current_screen); ObjectTypeDB::bind_method(_MD("get_screen_position","screen"),&_OS::get_screen_position,DEFVAL(0)); ObjectTypeDB::bind_method(_MD("get_screen_size","screen"),&_OS::get_screen_size,DEFVAL(0)); + ObjectTypeDB::bind_method(_MD("get_screen_dpi","screen"),&_OS::get_screen_dpi,DEFVAL(0)); ObjectTypeDB::bind_method(_MD("get_window_position"),&_OS::get_window_position); ObjectTypeDB::bind_method(_MD("set_window_position","position"),&_OS::set_window_position); ObjectTypeDB::bind_method(_MD("get_window_size"),&_OS::get_window_size); diff --git a/core/bind/core_bind.h b/core/bind/core_bind.h index 0c768651ff..af89536c45 100644 --- a/core/bind/core_bind.h +++ b/core/bind/core_bind.h @@ -117,6 +117,7 @@ public: virtual void set_current_screen(int p_screen); virtual Point2 get_screen_position(int p_screen=0) const; virtual Size2 get_screen_size(int p_screen=0) const; + virtual int get_screen_dpi(int p_screen=0) const; virtual Point2 get_window_position() const; virtual void set_window_position(const Point2& p_position); virtual Size2 get_window_size() const; diff --git a/core/os/os.h b/core/os/os.h index 160c0495bb..5fd2bd6c25 100644 --- a/core/os/os.h +++ b/core/os/os.h @@ -160,6 +160,7 @@ public: virtual void set_current_screen(int p_screen) { } virtual Point2 get_screen_position(int p_screen=0) const { return Point2(); } virtual Size2 get_screen_size(int p_screen=0) const { return get_window_size(); } + virtual int get_screen_dpi(int p_screen=0) const { return 72; } virtual Point2 get_window_position() const { return Vector2(); } virtual void set_window_position(const Point2& p_position) {} virtual Size2 get_window_size() const=0; -- cgit v1.2.3