Add love.window.getDisplayOrientation and a love.displayrotated callback. Resolves issue #1441.

Note that this tracks screen orientation, rather than device orientation.
This commit is contained in:
Alex Szpakowski
2018-12-17 16:19:56 -04:00
parent 43ee232897
commit d4762b4612
8 changed files with 134 additions and 0 deletions
+19
View File
@@ -86,6 +86,16 @@ public:
MESSAGEBOX_MAX_ENUM
};
enum DisplayOrientation
{
ORIENTATION_UNKNOWN,
ORIENTATION_LANDSCAPE,
ORIENTATION_LANDSCAPE_FLIPPED,
ORIENTATION_PORTRAIT,
ORIENTATION_PORTRAIT_FLIPPED,
ORIENTATION_MAX_ENUM
};
struct WindowSize
{
int width;
@@ -132,6 +142,8 @@ public:
virtual const char *getDisplayName(int displayindex) const = 0;
virtual DisplayOrientation getDisplayOrientation(int displayindex) const = 0;
virtual std::vector<WindowSize> getFullscreenSizes(int displayindex) const = 0;
virtual void getDesktopDimensions(int displayindex, int &width, int &height) const = 0;
@@ -206,6 +218,10 @@ public:
static bool getConstant(MessageBoxType in, const char *&out);
static std::vector<std::string> getConstants(MessageBoxType);
static bool getConstant(const char *in, DisplayOrientation &out);
static bool getConstant(DisplayOrientation in, const char *&out);
static std::vector<std::string> getConstants(DisplayOrientation);
private:
static StringMap<Setting, SETTING_MAX_ENUM>::Entry settingEntries[];
@@ -217,6 +233,9 @@ private:
static StringMap<MessageBoxType, MESSAGEBOX_MAX_ENUM>::Entry messageBoxTypeEntries[];
static StringMap<MessageBoxType, MESSAGEBOX_MAX_ENUM> messageBoxTypes;
static StringMap<DisplayOrientation, ORIENTATION_MAX_ENUM>::Entry orientationEntries[];
static StringMap<DisplayOrientation, ORIENTATION_MAX_ENUM> orientations;
}; // Window
struct WindowSettings