Przeglądaj źródła

Double up the editor UI when on High DPI display.

Yao Wei Tjong 姚伟忠 8 lat temu
rodzic
commit
1d3c20aa70

+ 1 - 0
Source/Urho3D/AngelScript/InputAPI.cpp

@@ -595,6 +595,7 @@ static void RegisterInput(asIScriptEngine* engine)
     engine->RegisterObjectMethod("Input", "int get_mouseMoveX() const", asMETHOD(Input, GetMouseMoveX), asCALL_THISCALL);
     engine->RegisterObjectMethod("Input", "int get_mouseMoveX() const", asMETHOD(Input, GetMouseMoveX), asCALL_THISCALL);
     engine->RegisterObjectMethod("Input", "int get_mouseMoveY() const", asMETHOD(Input, GetMouseMoveY), asCALL_THISCALL);
     engine->RegisterObjectMethod("Input", "int get_mouseMoveY() const", asMETHOD(Input, GetMouseMoveY), asCALL_THISCALL);
     engine->RegisterObjectMethod("Input", "int get_mouseMoveWheel() const", asMETHOD(Input, GetMouseMoveWheel), asCALL_THISCALL);
     engine->RegisterObjectMethod("Input", "int get_mouseMoveWheel() const", asMETHOD(Input, GetMouseMoveWheel), asCALL_THISCALL);
+    engine->RegisterObjectMethod("Input", "Vector2 get_inputScale() const", asMETHOD(Input, GetInputScale), asCALL_THISCALL);
     engine->RegisterObjectMethod("Input", "uint get_numTouches() const", asMETHOD(Input, GetNumTouches), asCALL_THISCALL);
     engine->RegisterObjectMethod("Input", "uint get_numTouches() const", asMETHOD(Input, GetNumTouches), asCALL_THISCALL);
     engine->RegisterObjectMethod("Input", "TouchState@+ get_touches(uint) const", asMETHOD(Input, GetTouch), asCALL_THISCALL);
     engine->RegisterObjectMethod("Input", "TouchState@+ get_touches(uint) const", asMETHOD(Input, GetTouch), asCALL_THISCALL);
     engine->RegisterObjectMethod("Input", "uint get_numJoysticks() const", asMETHOD(Input, GetNumJoysticks), asCALL_THISCALL);
     engine->RegisterObjectMethod("Input", "uint get_numJoysticks() const", asMETHOD(Input, GetNumJoysticks), asCALL_THISCALL);

+ 1 - 0
Source/Urho3D/Input/Input.cpp

@@ -325,6 +325,7 @@ Input::Input(Context* context) :
     mouseButtonPress_(0),
     mouseButtonPress_(0),
     lastVisibleMousePosition_(MOUSE_POSITION_OFFSCREEN),
     lastVisibleMousePosition_(MOUSE_POSITION_OFFSCREEN),
     mouseMoveWheel_(0),
     mouseMoveWheel_(0),
+    inputScale_(Vector2::ONE),
     windowID_(0),
     windowID_(0),
     toggleFullscreen_(true),
     toggleFullscreen_(true),
     mouseVisible_(false),
     mouseVisible_(false),

+ 2 - 0
Source/Urho3D/Input/Input.h

@@ -257,6 +257,8 @@ public:
     int GetMouseMoveY() const;
     int GetMouseMoveY() const;
     /// Return mouse wheel movement since last frame.
     /// Return mouse wheel movement since last frame.
     int GetMouseMoveWheel() const { return mouseMoveWheel_; }
     int GetMouseMoveWheel() const { return mouseMoveWheel_; }
+    /// Return input coordinate scaling. Should return non-unity on High DPI display.
+    Vector2 GetInputScale() const { return inputScale_; }
 
 
     /// Return number of active finger touches.
     /// Return number of active finger touches.
     unsigned GetNumTouches() const { return touches_.Size(); }
     unsigned GetNumTouches() const { return touches_.Size(); }

+ 2 - 0
Source/Urho3D/LuaScript/pkgs/Input/Input.pkg

@@ -87,6 +87,7 @@ class Input : public Object
     int GetMouseMoveX() const;
     int GetMouseMoveX() const;
     int GetMouseMoveY() const;
     int GetMouseMoveY() const;
     int GetMouseMoveWheel() const;
     int GetMouseMoveWheel() const;
+    Vector2 GetInputScale() const;
     unsigned GetNumTouches() const;
     unsigned GetNumTouches() const;
     TouchState* GetTouch(unsigned index) const;
     TouchState* GetTouch(unsigned index) const;
     unsigned GetNumJoysticks() const;
     unsigned GetNumJoysticks() const;
@@ -110,6 +111,7 @@ class Input : public Object
     tolua_readonly tolua_property__get_set int mouseMoveX;
     tolua_readonly tolua_property__get_set int mouseMoveX;
     tolua_readonly tolua_property__get_set int mouseMoveY;
     tolua_readonly tolua_property__get_set int mouseMoveY;
     tolua_readonly tolua_property__get_set int mouseMoveWheel;
     tolua_readonly tolua_property__get_set int mouseMoveWheel;
+    tolua_readonly tolua_property__get_set Vector2 inputScale;
     tolua_readonly tolua_property__get_set unsigned numTouches;
     tolua_readonly tolua_property__get_set unsigned numTouches;
     tolua_readonly tolua_property__get_set unsigned numJoysticks;
     tolua_readonly tolua_property__get_set unsigned numJoysticks;
     tolua_readonly tolua_property__get_set bool toggleFullscreen;
     tolua_readonly tolua_property__get_set bool toggleFullscreen;

+ 6 - 0
bin/Data/Scripts/Editor.as

@@ -59,6 +59,12 @@ void Start()
     cache.returnFailedResources = true;
     cache.returnFailedResources = true;
     // Use OS mouse without grabbing it
     // Use OS mouse without grabbing it
     input.mouseVisible = true;
     input.mouseVisible = true;
+    // If input is scaled the double the UI size (High DPI display)
+    if (input.inputScale != Vector2::ONE)
+    {
+        // Should we use the inputScale itself to scale UI?
+        ui.scale = 2;
+    }
     // Use system clipboard to allow transport of text in & out from the editor
     // Use system clipboard to allow transport of text in & out from the editor
     ui.useSystemClipboard = true;
     ui.useSystemClipboard = true;
 }
 }